activity-detector icon indicating copy to clipboard operation
activity-detector copied to clipboard

timeToIdle of 30 minutes not working

Open nickpassarella opened this issue 4 years ago • 2 comments

Is there an upper limit of some kind to timetoIdle? I'm using this to implement an auto logout. In tests at one minute or less, it works great. But when I set timeToIdle to 1800000, it fires the idle callback after about 10 seconds.

nickpassarella avatar Feb 03 '21 15:02 nickpassarella

I had the same issue when trying to make for 60 mins

Rolando-Barbella avatar Jun 22 '21 14:06 Rolando-Barbella

.... 3 Years later

For anyone else that ends up here like I did

The answer is in the init function

inactivityEvents.filter(eventName => eventName !== 'visibilitychange').forEach(eventName =>window.addEventListener(eventName, handleUserInactivityEvent));
if (inactivityEvents.indexOf('visibilitychange') >= 0 && visibilityChangeEvent) {document.addEventListener(visibilityChangeEvent, handleVisibilityChangeEvent);}

The init function has two types of extra listeners that no one realizes is there. These two listeners will run their call back, which can turn your timer to idle. In doing so, it looks like the timer doesn't work when that is not the case.

All you have to do is pass the settings to override the defaults for those two settings or copy and paste the code into your project and delete these specific lines in the init function.

GreenPioneer avatar Apr 25 '24 11:04 GreenPioneer