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

When idleStart is called don't toggleInterrupts(false) #5

Closed paullryan closed 8 years ago

paullryan commented 8 years ago

Currently in Idle.prototype.toggleState when idleStart triggers it triggers the this.toggleInterrupts(false) which never allows idleEnd to occur. Seems like there needs to be one more condition here of not just this.idling but also the parent that called toggleState.

paullryan commented 8 years ago

Seems related to #4

paullryan commented 8 years ago

Nevermind: See PR #6

Maybe something like

    Idle.prototype.timeout = function () {
        this.stopKeepalive();
        this.toggleInterrupts(false);
        this.safeClearInterval('idleHandle');
        this.safeClearInterval('timeoutHandle');
        this.idling = true;
        this.running = false;
        this.timedOut = true;
        this.countdown = 0;
        this.onTimeout.emit(null);
    };
   Idle.prototype.toggleState = function () {
        var _this = this;
        this.idling = !this.idling;
        if (this.timedOut) {
            this.toggleInterrupts(false);
        }
        if (this.idling) {
            this.onIdleStart.emit(null);
            this.stopKeepalive();
            if (this.timeoutVal > 0) {
                this.countdown = this.timeoutVal;
                this.doCountdown();
                this.timeoutHandle = setInterval(function () { _this.doCountdown(); }, 1000);
            }
        }
        else {
            this.timedOut = false;
            this.toggleInterrupts(true);
            this.onIdleEnd.emit(null);
            this.startKeepalive();
        }
        this.safeClearInterval('idleHandle');
    };
moribvndvs commented 8 years ago

Fixed in d8d600d