diff --git a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js index 1808d30660..06cc7289b3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js @@ -1,5 +1,5 @@ angular.module('umbraco.services') -.factory('userService', function ($rootScope, $q, $location, $log, securityRetryQueue, authResource, dialogService, $timeout) { +.factory('userService', function ($rootScope, $q, $location, $log, securityRetryQueue, authResource, dialogService, $timeout, angularHelper) { var currentUser = null; var lastUserId = null; @@ -60,8 +60,8 @@ angular.module('umbraco.services') this will continually count down their current remaining seconds every 2 seconds until there are no more seconds remaining. */ - function countdownUserTimeout() { - $timeout(function () { + function countdownUserTimeout() { + $timeout(function() { if (currentUser) { //countdown by 2 seconds since that is how long our timer is for. currentUser.remainingAuthSeconds -= 2; @@ -90,12 +90,17 @@ angular.module('umbraco.services') countdownUserTimeout(); } else { - + //we are either timed out or very close to timing out so we need to show the login dialog. - userAuthExpired(); + //NOTE: the safeApply because our timeout is set to not run digests (performance reasons) + angularHelper.safeApply($rootScope, function() { + userAuthExpired(); + }); + } - } - }, 2000);//every 2 seconds + } + }, 2000, //every 2 seconds + false); //false = do NOT execute a digest for every iteration } /** Called to update the current user's timeout */ diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/user.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/user.controller.js index ceac0f36f4..877ad7d351 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/user.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/user.controller.js @@ -1,5 +1,5 @@ angular.module("umbraco") - .controller("Umbraco.Dialogs.UserController", function ($scope, $location, userService, historyService) { + .controller("Umbraco.Dialogs.UserController", function ($scope, $location, $timeout, userService, historyService) { $scope.user = userService.getCurrentUser(); $scope.history = historyService.current; @@ -13,5 +13,17 @@ angular.module("umbraco") $scope.gotoHistory = function (link) { $location.path(link); $scope.hide(); - }; -}); \ No newline at end of file + }; + + //Manually update the remaining timeout seconds + function updateTimeout() { + $timeout(function () { + $scope.user = userService.getCurrentUser(); + //manually execute the digest against this scope only + $scope.$digest(); + updateTimeout(); //keep going (recurse) + }, 1000, false); // 1 second, do NOT execute a global digest + } + updateTimeout(); + + }); \ No newline at end of file