Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Always allow interrupt when initiated by a change in session expiry date from another tab #129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/idle/idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])

stopKeepalive();
},
interrupt: function(noExpiryUpdate) {
interrupt: function(anotherTab) {
if (!state.running) return;

if (options.timeout && this.isExpired()) {
Expand All @@ -191,7 +191,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
}

// note: you can no longer auto resume once we exceed the expiry; you will reset state by calling watch() manually
if (options.autoResume === 'idle' || (options.autoResume === 'notIdle' && !state.idling)) this.watch(noExpiryUpdate);
if (anotherTab || options.autoResume === 'idle' || (options.autoResume === 'notIdle' && !state.idling)) this.watch(anotherTab);
}
};

Expand Down
17 changes: 17 additions & 0 deletions src/idle/idle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,23 @@ describe('ngIdle', function() {
Idle.interrupt();
expect(Idle.watch).not.toHaveBeenCalled();
});

it ('interrupt(true) should call watch() if idle and autoResume is notIdle', function() {
IdleProvider.autoResume('notIdle');
Idle = create();

spyOn(Idle, 'watch').andCallThrough();

// arrange
Idle.watch(); // start watching
Idle.watch.reset(); // reset watch spy to ignore the prior setup call

$interval.flush(DEFAULTIDLEDURATION);

Idle.interrupt(true);
expect(Idle.watch).toHaveBeenCalled();
});

});

describe('Idle with timeout disabled', function() {
Expand Down