Fix several minor runtime bugs in the app

This commit is contained in:
Tankred Hase 2014-11-26 17:57:14 +01:00
parent 2b6da522c6
commit b3b947f6e5
12 changed files with 62 additions and 45 deletions

View File

@ -2,6 +2,9 @@
var AccountCtrl = function($scope, auth, keychain, pgp, appConfig, download, dialog) { var AccountCtrl = function($scope, auth, keychain, pgp, appConfig, download, dialog) {
var userId = auth.emailAddress; var userId = auth.emailAddress;
if (!userId) {
return;
}
$scope.state.account = { $scope.state.account = {
toggle: function(to) { toggle: function(to) {

View File

@ -1,31 +1,41 @@
'use strict'; 'use strict';
var DialogCtrl = function($scope, dialog) { var DialogCtrl = function($scope, $timeout, dialog) {
$scope.state.dialog = {
open: false
};
// //
// Set dialog disply functions // Set dialog disply functions
// //
dialog.displayInfo = function(options) { dialog.displayInfo = function(options) {
setOptions(options); return $timeout(function() {
setOptions(options);
});
}; };
dialog.displayError = function(options) { dialog.displayError = function(options) {
if (!options) { return $timeout(function() {
return; if (!options) {
} return;
}
setOptions(options); setOptions(options);
$scope.title = options.title || 'Error'; $scope.title = options.title || 'Error';
$scope.showBugReporter = (typeof options.showBugReporter !== 'undefined' ? options.showBugReporter : !options.title); // if title is set, presume it's not an error by default $scope.showBugReporter = (typeof options.showBugReporter !== 'undefined' ? options.showBugReporter : !options.title); // if title is set, presume it's not an error by default
});
}; };
dialog.displayConfirm = function(options) { dialog.displayConfirm = function(options) {
setOptions(options); return $timeout(function() {
setOptions(options);
});
}; };
function setOptions(options) { function setOptions(options) {
$scope.open = true; $scope.state.dialog.open = true;
$scope.title = options.title; $scope.title = options.title;
$scope.message = options.errMsg || options.message; $scope.message = options.errMsg || options.message;
$scope.faqLink = options.faqLink; $scope.faqLink = options.faqLink;
@ -40,7 +50,7 @@ var DialogCtrl = function($scope, dialog) {
// //
$scope.confirm = function(ok) { $scope.confirm = function(ok) {
$scope.open = false; $scope.state.dialog.open = false;
if ($scope.callback) { if ($scope.callback) {
$scope.callback(ok); $scope.callback(ok);

View File

@ -229,7 +229,7 @@ var MailListCtrl = function($scope, $routeParams, statusDisplay, notification, e
} }
function currentFolder() { function currentFolder() {
return $scope.state.nav.currentFolder; return $scope.state.nav && $scope.state.nav.currentFolder;
} }
function currentMessage() { function currentMessage() {

View File

@ -14,7 +14,10 @@ var NOTIFICATION_SENT_TIMEOUT = 2000;
// //
var NavigationCtrl = function($scope, $routeParams, $location, account, email, outbox, notification, appConfig, dialog) { var NavigationCtrl = function($scope, $routeParams, $location, account, email, outbox, notification, appConfig, dialog) {
!$routeParams.dev && !account.isLoggedIn() && $location.path('/'); // init app if (!$routeParams.dev && !account.isLoggedIn()) {
$location.path('/'); // init app
return;
}
var str = appConfig.string, var str = appConfig.string,
config = appConfig.config; config = appConfig.config;

View File

@ -1,15 +1,25 @@
'use strict'; 'use strict';
var StatusDisplayCtrl = function($scope, statusDisplay) { var StatusDisplayCtrl = function($scope, $timeout, statusDisplay) {
$scope.state.statusDisplay = {
text: '',
time: undefined,
searching: false
};
// set the show functions // set the show functions
statusDisplay.showStatus = function(lbl, time) { statusDisplay.showStatus = function(lbl, time) {
$scope.lastUpdateLbl = lbl; return $timeout(function() {
$scope.lastUpdate = (time) ? time : ''; $scope.state.statusDisplay.text = lbl;
$scope.state.statusDisplay.time = (time) ? time : '';
});
}; };
statusDisplay.showSearching = function(state) { statusDisplay.showSearching = function(state) {
$scope.searching = state; return $timeout(function() {
$scope.state.statusDisplay.searching = state;
});
}; };
}; };

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
var LoginCtrl = function($scope, $location, updateHandler, account, auth, email, keychain, dialog) { var LoginCtrl = function($scope, $timeout, $location, updateHandler, account, auth, email, keychain, dialog) {
// check for app update // check for app update
updateHandler.checkForUpdate(); updateHandler.checkForUpdate();
@ -85,7 +85,7 @@ var LoginCtrl = function($scope, $location, updateHandler, account, auth, email,
} }
function goTo(location) { function goTo(location) {
$scope.$apply(function() { return $timeout(function() {
$location.path(location); $location.path(location);
}); });
} }

View File

@ -168,8 +168,8 @@ Account.prototype.onConnect = function() {
pgpMailer.onError = onConnectionError; pgpMailer.onError = onConnectionError;
// certificate update handling // certificate update handling
imapClient.onCert = self._auth.handleCertificateUpdate.bind(self._auth, 'imap', self.onConnect, self._dialog.error); imapClient.onCert = self._auth.handleCertificateUpdate.bind(self._auth, 'imap', self.onConnect.bind(self), self._dialog.error);
pgpMailer.onCert = self._auth.handleCertificateUpdate.bind(self._auth, 'smtp', self.onConnect, self._dialog.error); pgpMailer.onCert = self._auth.handleCertificateUpdate.bind(self._auth, 'smtp', self.onConnect.bind(self), self._dialog.error);
// connect to clients // connect to clients
self._emailDao.onConnect({ self._emailDao.onConnect({

View File

@ -60,8 +60,7 @@ Dialog.prototype.confirm = function(options) {
Dialog.prototype._handle = function(options, fn, errMsg) { Dialog.prototype._handle = function(options, fn, errMsg) {
return this._q(function(resolve, reject) { return this._q(function(resolve, reject) {
if (fn) { if (fn) {
fn(options); return resolve(fn(options));
resolve();
} else { } else {
reject(new Error('Dialog service ' + errMsg + ' not set!')); reject(new Error('Dialog service ' + errMsg + ' not set!'));
} }

View File

@ -22,8 +22,7 @@ StatusDisplay.prototype.update = function(msg, time) {
self._axe.info('status display', msg); self._axe.info('status display', msg);
return self._q(function(resolve, reject) { return self._q(function(resolve, reject) {
if (self.showStatus) { if (self.showStatus) {
self.showStatus(msg, time); return resolve(self.showStatus(msg, time));
resolve();
} else { } else {
reject(new Error('Status display service showStatus not set!')); reject(new Error('Status display service showStatus not set!'));
} }
@ -38,8 +37,7 @@ StatusDisplay.prototype.setSearching = function(state) {
var self = this; var self = this;
return self._q(function(resolve, reject) { return self._q(function(resolve, reject) {
if (self.showSearching) { if (self.showSearching) {
self.showSearching(state); return resolve(self.showSearching(state));
resolve();
} else { } else {
reject(new Error('Status display service showSearching not set!')); reject(new Error('Status display service showSearching not set!'));
} }

View File

@ -12,6 +12,7 @@
<svg><use xlink:href="#icon-write" /><title>New mail</title></svg> <svg><use xlink:href="#icon-write" /><title>New mail</title></svg>
</button> </button>
</header> </header>
<div class="mail-list__search"> <div class="mail-list__search">
<div class="search"> <div class="search">
<svg><use xlink:href="#icon-search" /><title>Search</title></svg> <svg><use xlink:href="#icon-search" /><title>Search</title></svg>
@ -71,13 +72,5 @@
</ul> </ul>
</div> </div>
<footer ng-controller="StatusDisplayCtrl"> <footer ng-include="'tpl/status-display.html'"></footer>
<span class="spinner" ng-show="account.loggingIn || account.busy || searching"></span>
<span class="text" ng-switch="account.online">
<span ng-switch-when="false">
<svg><use xlink:href="#icon-offline" /></svg>
</span>
{{lastUpdateLbl}} {{lastUpdate | date:'shortTime'}}
</span>
</footer>
</div> </div>

View File

@ -69,13 +69,5 @@
</li> </li>
</ul><!--/nav__secondary--> </ul><!--/nav__secondary-->
<footer ng-controller="StatusDisplayCtrl"> <footer ng-include="'tpl/status-display.html'" ng-controller="StatusDisplayCtrl"></footer>
<span class="spinner" ng-show="account.loggingIn || account.busy || searching"></span>
<span class="text" ng-switch="account.online">
<span ng-switch-when="false">
<svg><use xlink:href="#icon-offline" /></svg>
</span>
{{lastUpdateLbl}} {{lastUpdate | date:'shortTime'}}
</span>
</footer>
</nav> </nav>

View File

@ -0,0 +1,9 @@
<div>
<span class="spinner" ng-show="account.loggingIn || account.busy || state.statusDisplay.searching"></span>
<span class="text" ng-switch="account.online">
<span ng-switch-when="false">
<svg><use xlink:href="#icon-offline" /></svg>
</span>
{{state.statusDisplay.text}} {{state.statusDisplay.time | date:'shortTime'}}
</span>
</div>