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 userId = auth.emailAddress;
if (!userId) {
return;
}
$scope.state.account = {
toggle: function(to) {

View File

@ -1,31 +1,41 @@
'use strict';
var DialogCtrl = function($scope, dialog) {
var DialogCtrl = function($scope, $timeout, dialog) {
$scope.state.dialog = {
open: false
};
//
// Set dialog disply functions
//
dialog.displayInfo = function(options) {
setOptions(options);
return $timeout(function() {
setOptions(options);
});
};
dialog.displayError = function(options) {
if (!options) {
return;
}
return $timeout(function() {
if (!options) {
return;
}
setOptions(options);
$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
setOptions(options);
$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
});
};
dialog.displayConfirm = function(options) {
setOptions(options);
return $timeout(function() {
setOptions(options);
});
};
function setOptions(options) {
$scope.open = true;
$scope.state.dialog.open = true;
$scope.title = options.title;
$scope.message = options.errMsg || options.message;
$scope.faqLink = options.faqLink;
@ -40,7 +50,7 @@ var DialogCtrl = function($scope, dialog) {
//
$scope.confirm = function(ok) {
$scope.open = false;
$scope.state.dialog.open = false;
if ($scope.callback) {
$scope.callback(ok);

View File

@ -229,7 +229,7 @@ var MailListCtrl = function($scope, $routeParams, statusDisplay, notification, e
}
function currentFolder() {
return $scope.state.nav.currentFolder;
return $scope.state.nav && $scope.state.nav.currentFolder;
}
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) {
!$routeParams.dev && !account.isLoggedIn() && $location.path('/'); // init app
if (!$routeParams.dev && !account.isLoggedIn()) {
$location.path('/'); // init app
return;
}
var str = appConfig.string,
config = appConfig.config;

View File

@ -1,15 +1,25 @@
'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
statusDisplay.showStatus = function(lbl, time) {
$scope.lastUpdateLbl = lbl;
$scope.lastUpdate = (time) ? time : '';
return $timeout(function() {
$scope.state.statusDisplay.text = lbl;
$scope.state.statusDisplay.time = (time) ? time : '';
});
};
statusDisplay.showSearching = function(state) {
$scope.searching = state;
return $timeout(function() {
$scope.state.statusDisplay.searching = state;
});
};
};

View File

@ -1,6 +1,6 @@
'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
updateHandler.checkForUpdate();
@ -85,7 +85,7 @@ var LoginCtrl = function($scope, $location, updateHandler, account, auth, email,
}
function goTo(location) {
$scope.$apply(function() {
return $timeout(function() {
$location.path(location);
});
}

View File

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

View File

@ -60,8 +60,7 @@ Dialog.prototype.confirm = function(options) {
Dialog.prototype._handle = function(options, fn, errMsg) {
return this._q(function(resolve, reject) {
if (fn) {
fn(options);
resolve();
return resolve(fn(options));
} else {
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);
return self._q(function(resolve, reject) {
if (self.showStatus) {
self.showStatus(msg, time);
resolve();
return resolve(self.showStatus(msg, time));
} else {
reject(new Error('Status display service showStatus not set!'));
}
@ -38,8 +37,7 @@ StatusDisplay.prototype.setSearching = function(state) {
var self = this;
return self._q(function(resolve, reject) {
if (self.showSearching) {
self.showSearching(state);
resolve();
return resolve(self.showSearching(state));
} else {
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>
</button>
</header>
<div class="mail-list__search">
<div class="search">
<svg><use xlink:href="#icon-search" /><title>Search</title></svg>
@ -71,13 +72,5 @@
</ul>
</div>
<footer ng-controller="StatusDisplayCtrl">
<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>
<footer ng-include="'tpl/status-display.html'"></footer>
</div>

View File

@ -69,13 +69,5 @@
</li>
</ul><!--/nav__secondary-->
<footer ng-controller="StatusDisplayCtrl">
<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>
<footer ng-include="'tpl/status-display.html'" ng-controller="StatusDisplayCtrl"></footer>
</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>