mirror of
https://github.com/moparisthebest/mail
synced 2025-01-12 22:18:03 -05:00
Review code
This commit is contained in:
parent
7b5ed03716
commit
3a0d71b645
@ -157,16 +157,15 @@ define(function(require) {
|
||||
openCurrentFolder();
|
||||
});
|
||||
|
||||
$scope.$watch('state.nav.currentFolder.messages', selectFirstMessage);
|
||||
$scope.$watch('state.nav.currentFolder.messages.length', selectFirstMessage);
|
||||
$scope.$watchCollection('state.nav.currentFolder.messages', selectFirstMessage);
|
||||
|
||||
function selectFirstMessage() {
|
||||
if (!currentMessages()) {
|
||||
function selectFirstMessage(messages) {
|
||||
if (!messages) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Shows the next message based on the uid of the currently selected element
|
||||
if (currentMessages().indexOf(currentMessage()) === -1) {
|
||||
if (messages.indexOf(currentMessage()) === -1) {
|
||||
// wait until after first $digest() so $scope.filteredMessages is set
|
||||
$timeout(function() {
|
||||
$scope.select($scope.filteredMessages ? $scope.filteredMessages[0] : undefined);
|
||||
@ -211,10 +210,6 @@ define(function(require) {
|
||||
return $scope.state.nav.currentFolder;
|
||||
}
|
||||
|
||||
function currentMessages() {
|
||||
return currentFolder() && currentFolder().messages;
|
||||
}
|
||||
|
||||
function currentMessage() {
|
||||
return $scope.state.mailList.selected;
|
||||
}
|
||||
|
@ -171,13 +171,13 @@ define(function(require) {
|
||||
};
|
||||
|
||||
EmailDAO.prototype.openFolder = function(options, callback) {
|
||||
var self = this;
|
||||
var self = this,
|
||||
err;
|
||||
|
||||
if (!self._account.online) {
|
||||
callback({
|
||||
errMsg: 'Client is currently offline!',
|
||||
code: 42
|
||||
});
|
||||
err = new Error('Client is currently offline!');
|
||||
err.code = 42;
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -817,7 +817,7 @@ define(function(require) {
|
||||
self._imapClient = options.imapClient;
|
||||
self._pgpMailer = options.pgpMailer;
|
||||
|
||||
this._imapClient.login(function(err) {
|
||||
self._imapClient.login(function(err) {
|
||||
self._account.loggingIn = false;
|
||||
|
||||
if (err) {
|
||||
@ -981,7 +981,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
self._account.folders = stored[0] || [];
|
||||
readCache();
|
||||
readMessagesFromDisk();
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
@ -1028,7 +1028,7 @@ define(function(require) {
|
||||
});
|
||||
|
||||
if (!foldersChanged) {
|
||||
readCache();
|
||||
readMessagesFromDisk();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1039,13 +1039,13 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
readCache();
|
||||
readMessagesFromDisk();
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function readCache() {
|
||||
function readMessagesFromDisk() {
|
||||
if (!self._account.folders || self._account.folders.length === 0) {
|
||||
done();
|
||||
return;
|
||||
@ -1060,6 +1060,7 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
// sync: messages on disk -> scope
|
||||
self.refreshFolder({
|
||||
folder: folder
|
||||
}, function(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user