How can I control the timing of a user with a button?
Currently, I can start multiple timers for different users at the same time. Is there a way to only start one timer at a time? I want the ability to pause the previous timer when starting a new one.
Is there a method to achieve this functionality?
html
<button id="button-basic" dropdownToggle aria-controls="dropdown-basic">
<img *ngIf="taskService.timerForUsers[data.key.ID]?.currentState === 'pause' || taskService.timerForUsers[data.key.ID] == undefined" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQcW6cJlI-KlS721hkuHDTMydZ_snrkhL9sm9wYHWRhd3FlvF1b&s" width="50" height="50">
<img *ngIf="taskService.timerForUsers[data.key.ID]?.currentState ==='start'"
src="https://png.pngtree.com/png-clipart/20190516/original/pngtree-pause-vector-icon-png-image_3791321.jpg" width="50" height="50">
<img *ngIf="!taskService.timerForUsers[data.key.ID]?.currentState ==='start'"
src="https://png.pngtree.com/png-clipart/20190516/original/pngtree-pause-vector-icon-png-image_3791321.jpg" width="50" height="50">
</button>
<ul id="dropdown-basic" *dropdownMenu class="dropdown-menu" role="menu" aria-labelledby="button-basic">
<li role="menuitem"><a class="dropdown-item"
*ngIf="!taskService.timerForUsers[data.key.ID] || taskService.timerForUsers[data.key.ID].currentState === 'pause'"
routerLinkActive="active" (click)="startTimer(data)">Start</a></li>
<li role="menuitem"><a class="dropdown-item"
*ngIf="taskService.timerForUsers[data.key.ID]?.currentState === 'start'"
routerLinkActive="active" (click)="pauseTimer(data)">Stop</a></li>
</ul>