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

Commit

Permalink
Fixes #75 by updating countdown within evalAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
grbsk committed Apr 29, 2015
1 parent 899e89b commit afc379d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
12 changes: 6 additions & 6 deletions angular-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
function getExpiry() {
var obj = LocalStorage.get('expiry');

return new Date(obj.time);
return obj && obj.time ? new Date(obj.time) : null;
}

function setExpiry(date) {
Expand Down Expand Up @@ -228,7 +228,7 @@ angular.module('ngIdle.idle', ['ngIdle.keepalive', 'ngIdle.localStorage'])
},
isExpired: function() {
var expiry = getExpiry();
return expiry && expiry <= this._getNow();
return expiry !== null && expiry <= this._getNow();
},
running: function() {
return state.running;
Expand Down Expand Up @@ -307,13 +307,13 @@ angular.module('ngIdle.countdown', ['ngIdle.idle'])
$scope.value = Idle.getTimeout();

$scope.$on('IdleWarn', function(e, countdown) {
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.value = countdown;
});
});

$scope.$on('IdleTimeout', function() {
$scope.$apply(function() {
$scope.$evalAsync(function() {
$scope.value = 0;
});
});
Expand Down Expand Up @@ -407,7 +407,7 @@ angular.module('ngIdle.title', [])
angular.module('ngIdle.localStorage', [])
.service('IdleLocalStorage', ['$window', function($window) {
var storage = $window.localStorage;

return {
set: function(key, value) {
storage.setItem('ngIdle.'+key, angular.toJson(value));
Expand All @@ -421,4 +421,4 @@ angular.module('ngIdle.localStorage', [])
};
}]);

})(window, window.angular);
})(window, window.angular);
2 changes: 1 addition & 1 deletion angular-idle.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit afc379d

Please sign in to comment.