diff --git a/src/js/controller/app/mail-list.js b/src/js/controller/app/mail-list.js index 0daa922..460c2e7 100644 --- a/src/js/controller/app/mail-list.js +++ b/src/js/controller/app/mail-list.js @@ -11,7 +11,7 @@ var INIT_DISPLAY_LEN = 20, FOLDER_TYPE_INBOX = 'Inbox', NOTIFICATION_INBOX_TIMEOUT = 5000; -var MailListCtrl = function($scope, $routeParams, statusDisplay, notification, email, keychain, dialog, search, dummy) { +var MailListCtrl = function($scope, $timeout, $routeParams, statusDisplay, notification, email, keychain, dialog, search, dummy) { // // Init @@ -197,12 +197,15 @@ var MailListCtrl = function($scope, $routeParams, statusDisplay, notification, e * Sync current folder when client comes back online */ $scope.watchOnline = $scope.$watch('account.online', function(isOnline) { - if (isOnline) { - statusDisplay.update('Online'); - openCurrentFolder(); - } else { - statusDisplay.update('Offline mode'); - } + // wait one cycle for the status display controllers to init + $timeout(function() { + if (isOnline) { + statusDisplay.update('Online'); + openCurrentFolder(); + } else { + statusDisplay.update('Offline mode'); + } + }); }, true); // diff --git a/src/js/controller/app/status-display.js b/src/js/controller/app/status-display.js index ce021f7..f20c898 100644 --- a/src/js/controller/app/status-display.js +++ b/src/js/controller/app/status-display.js @@ -1,26 +1,15 @@ 'use strict'; -var StatusDisplayCtrl = function($scope, $timeout, statusDisplay) { +var StatusDisplayCtrl = function($scope) { - $scope.state.statusDisplay = { - text: '', - time: undefined, - searching: false - }; + $scope.$on('status', function(e, text, time) { + $scope.text = text; + $scope.time = (time) ? time : ''; + }); - // set the show functions - statusDisplay.showStatus = function(lbl, time) { - return $timeout(function() { - $scope.state.statusDisplay.text = lbl; - $scope.state.statusDisplay.time = (time) ? time : ''; - }); - }; - - statusDisplay.showSearching = function(state) { - return $timeout(function() { - $scope.state.statusDisplay.searching = state; - }); - }; + $scope.$on('searching', function(e, state) { + $scope.searching = state; + }); }; diff --git a/src/js/util/status-display.js b/src/js/util/status-display.js index e0961c4..4379b18 100644 --- a/src/js/util/status-display.js +++ b/src/js/util/status-display.js @@ -7,26 +7,19 @@ module.exports = StatusDisplay; /** * A central service to display status updates to the user */ -function StatusDisplay($q, axe) { - this._q = $q; +function StatusDisplay($rootScope, axe) { + this._rootScope = $rootScope; this._axe = axe; } /** * Update the status disply in the lower left of the screen - * @param {String} msg The status message that is to be displayed to the user + * @param {String} text The status message that is to be displayed to the user * @param {Date} time The time of the last update */ -StatusDisplay.prototype.update = function(msg, time) { - var self = this; - self._axe.info('status display', msg); - return self._q(function(resolve, reject) { - if (self.showStatus) { - return resolve(self.showStatus(msg, time)); - } else { - reject(new Error('Status display service showStatus not set!')); - } - }); +StatusDisplay.prototype.update = function(text, time) { + this._axe.info('status display', text); + this._rootScope.$broadcast('status', text, time); }; /** @@ -34,12 +27,5 @@ StatusDisplay.prototype.update = function(msg, time) { * @param {Boolean} state If the spinner should be displayed or not */ StatusDisplay.prototype.setSearching = function(state) { - var self = this; - return self._q(function(resolve, reject) { - if (self.showSearching) { - return resolve(self.showSearching(state)); - } else { - reject(new Error('Status display service showSearching not set!')); - } - }); + this._rootScope.$broadcast('searching', state); }; \ No newline at end of file diff --git a/src/tpl/nav.html b/src/tpl/nav.html index 188aad3..575ee37 100644 --- a/src/tpl/nav.html +++ b/src/tpl/nav.html @@ -69,5 +69,5 @@ - + \ No newline at end of file diff --git a/src/tpl/status-display.html b/src/tpl/status-display.html index 3a441f9..55f16d9 100644 --- a/src/tpl/status-display.html +++ b/src/tpl/status-display.html @@ -1,9 +1,9 @@ -