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

Commit afc379d

Browse files
committed
Fixes #75 by updating countdown within evalAsync
1 parent 899e89b commit afc379d

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

angular-idle.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
199199
function getExpiry() {
200200
var obj = LocalStorage.get('expiry');
201201

202-
return new Date(obj.time);
202+
return obj && obj.time ? new Date(obj.time) : null;
203203
}
204204

205205
function setExpiry(date) {
@@ -228,7 +228,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
228228
},
229229
isExpired: function() {
230230
var expiry = getExpiry();
231-
return expiry && expiry <= this._getNow();
231+
return expiry !== null && expiry <= this._getNow();
232232
},
233233
running: function() {
234234
return state.running;
@@ -307,13 +307,13 @@ angular.module('ngIdle.countdown', ['ngIdle.idle'])
307307
$scope.value = Idle.getTimeout();
308308

309309
$scope.$on('IdleWarn', function(e, countdown) {
310-
$scope.$apply(function() {
310+
$scope.$evalAsync(function() {
311311
$scope.value = countdown;
312312
});
313313
});
314314

315315
$scope.$on('IdleTimeout', function() {
316-
$scope.$apply(function() {
316+
$scope.$evalAsync(function() {
317317
$scope.value = 0;
318318
});
319319
});
@@ -407,7 +407,7 @@ angular.module('ngIdle.title', [])
407407
angular.module('ngIdle.localStorage', [])
408408
.service('IdleLocalStorage', ['$window', function($window) {
409409
var storage = $window.localStorage;
410-
410+
411411
return {
412412
set: function(key, value) {
413413
storage.setItem('ngIdle.'+key, angular.toJson(value));
@@ -421,4 +421,4 @@ angular.module('ngIdle.localStorage', [])
421421
};
422422
}]);
423423

424-
})(window, window.angular);
424+
})(window, window.angular);

angular-idle.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)