I followed the answer from here: https://stackoverflow.com/a/59346314/12360035 I already have a timer implemented according to this answer: https://stackoverflow.com/a/64374454/12360035 My solution apparently only counts down to 14:59 and gets stuck there. How to fix this? My HTML:
<p> {{ this.authenticationService.countDown$ | async | date:'mm:ss' }} </p>
Changed the timer to the following code and now it starts counting from 00:00 and instantly jumps to 59:59 and starts counting down but after some time it freezes at 00:00. It should be a 15 minutes countdown. My modified code:
StartTimer() {
this.countDown$ = merge(
fromEvent(document, 'mousedown'),
fromEvent(document, 'mousemove'),
fromEvent(document, 'click'),
fromEvent(document, 'keydown'),
fromEvent(document, 'scroll')
).pipe(
startWith(false),
switchMap(_ => {
// * 1000 to turn the number into miliseconds
let counter = (15 * 60 * 1000) + 1;
return timer(0, 1000).pipe(
take(counter),
// count down in ms!!
map(_ => --counter * 1000),
tap(null, null, () => {
console.log('countdown complete');
// redirect to login page
window.location.href = 'http://IPHERE:8080/logout';
})
);
})
);