moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

Timeout is not occurring as per configured setTimeout. #61

Open devendrar opened 6 years ago

devendrar commented 6 years ago

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help

Current behavior If we set the setIdle to whatever seconds. It doesn't raise onIdleStart event as per configured time. This happens normally if we set the timeInterval more than 5 seconds.

this.idle.setIdle(30);

It has been observed from console logs that the last value calculation is wrong. last value from LocalStorageExpiry.last() is coming wrong. Below is the sample code -

this.idle.setIdle(30);
const idleTimeout: number = parseInt(10); // sets a timeout period of 5 seconds. after 10 seconds of inactivity, the user will be considered timed out. // sets the default interrupts, in this case, things like clicks, scrolls, touches to the document this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);

    const timeout = this.idle.getTimeout();

    this.idle.onIdleEnd.subscribe(() => {
        this.logger.debug('You are no longer idle. Click "OK" to close the warning dialog')
    });
    this.idle.onTimeout.subscribe(() => {
        this.logger.debug('Timed out!');          
    });

    this.idle.onIdleStart.subscribe(
        () => {
            this.logger.debug('You have gone idle. Idle time period started');
        });
    this.idle.onTimeoutWarning.subscribe((countdown: any) => {
        this.logger.warn('timed out warning dialog - ' + countdown);

    });

    // sets the ping interval to 15 seconds
    this.keepalive.interval(15);

    this.keepalive.onPing.subscribe(() =>
        log("KeepAlive call"));

    this.idle.setTimeout(idleTimeout);
    const timeOutInterval = this.idle.getTimeout(); 

    this.idle.watch(); 

Expected behavior The onIdleStart event should raised based on setIdle configuration.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Please tell us about your environment: OS10