Closed shkopa1 closed 1 year ago
Hi @shkopa1,
I believe I can accommodate this. I will put it on the roadmap for the next release.
great, thank you @SupremeTechnopriest . when is the next release scheduled for? Is there any quick solution I can use now as a workaround until next release?
You could track your own timestamps using onAction. I think I could get this out fairly quickly. Maybe this weekend I can carve out some time to get a patch out.
That would be amazing, thank you! looking forward to it!
Hi, are there any updates? :)
I did a little work on this today, from what I can tell, the existing code should handle this case unless performance.now
epoch is being reset when the computer sleeps. I'm adding in a Date.now
sanity check as a backup. Will push a release candidate tomorrow for you to test.
I tested it on the Demo in your site too with this scenario: idle time set to 5 min 10:00 - start timer 10:01 - put the computer to sleep (after 1 min) 10:07 - i woke it up (after 6 minutes of sleep) i saw the timer continues from the point it was asleep (as if only 1 min has passed) and it kept counting 4 more minutes, even though in absolute time, it was already 7 minutes after starting the timer, and idle time is set to 5 min.
i would love to get your update to test it tomorrow. thank you.
Hi, was it pushed ?
Working on a few other things for this release. I'll have it out today.
@shkopa1 Published as 5.4.2
! Reopen this issue if it doesn't fix the problem.
thank you!! i updated the package, but it still does not count the time in sleep (also in the demo). maybe i'm doing something wrong?
here is what i did: i printed from onAction() the getRemainingTime - which supposed to return the remaining time until idle then I put the comp to sleep for 15 min and when i returned i printed again getRemainingTime - and it seems like only 3 min have passed. not 15. so the sleep time does not count for idle.
am i doing something wrong?
thanks.
Ah, you are using the get functions. So the patch is just going to ensure that onIdle gets called. In v5 I switched to performance.now for more accurate timing, but I may need to switch back to Date.now to make all the functions work with sync. The good thing about performance.now is that changing the clock time wouldn't affect the timers. Maybe I should allow the developer to choose which date functions they want to use.
i'm actually not really using the functions, i just wanted to see if the issue was fixed. but after you comment now - i did another check, without the functions, and it still did not work:
meaning - the sleep time still does not count as idle time
So the act of waking up the computer and focusing the browser is considered user activity (by default) and will reset the timer. If you were to set timeout for 5 mins, and put the computer to sleep for 6 mins, when you come back onIdle should be called.
ok thanks! so i made some more tests:
Yeah its going to require an event to take place in order to do the check. I will try to make it detect the wake event. Im gong to make this work with all the methods as well in the next release.
Hi again, i just realized that this fix (still counting the time in sleep mode) makes the timer not work across tabs, is that right? when there is only one tab - it works (with sleep and without) but when i have more than 1 tab - it suddenly does not reach onIdle. Even when i'm not in sleep mode.
Hmm. It shouldn't affect cross tab as it stands. I will have a new version out this weekend that uses dates everywhere so we should have more consistent behavior. Can you show me how you are setting up cross tab?
This has been resolved and will be published in the next release.
Hi, thank you for the great repo! In the new version, when i put my computer to sleep (even on the demo in https://idletimer.dev/) - the timer stops. when i return, the timer resumes from the same point it was asleep. (so the time the computer was asleep does not count)
Is there a way to make the timer keep working while in sleep mode? something like - once the computer "awakes" - check if we have reached the timeout since last action, and if so - immediately invoke the onIdle() ?
these are my configurations: { timeout: 180000000 // 5 hours crossTab: true, syncTimers: 200, events: ["keydown", "mousedown"] };
thanks, Danielle