mirror of
https://github.com/moparisthebest/mail
synced 2025-01-31 15:10:13 -05:00
[WO-163] make pending mails visible in offline mode
This commit is contained in:
parent
798b68cc7e
commit
cb8ffe6f7b
@ -252,7 +252,6 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendEncrypted(email) {
|
function sendEncrypted(email) {
|
||||||
removeFromPendingMails(email);
|
|
||||||
self._emailDao.sendEncrypted({
|
self._emailDao.sendEncrypted({
|
||||||
email: email
|
email: email
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@ -267,6 +266,9 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the email has been sent, remove from pending mails
|
||||||
|
removeFromPendingMails(email);
|
||||||
|
|
||||||
// fire sent notification
|
// fire sent notification
|
||||||
self._onSent(email);
|
self._onSent(email);
|
||||||
|
|
||||||
|
@ -39,15 +39,50 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.onOutboxUpdate = function(err, count) {
|
$scope.onOutboxUpdate = function(err, count) {
|
||||||
|
var outbox, mail;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
$scope.onError(err);
|
$scope.onError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outbox = _.findWhere($scope.account.folders, {
|
outbox = _.findWhere($scope.account.folders, {
|
||||||
type: 'Outbox'
|
type: 'Outbox'
|
||||||
});
|
});
|
||||||
|
// update the outbox mail count
|
||||||
outbox.count = count;
|
outbox.count = count;
|
||||||
|
|
||||||
|
// if we're NOT viewing the outbox or we're not looking at any mail now, we're done
|
||||||
|
if ($scope.state.nav.currentFolder !== outbox || !$scope.state.mailList.selected) {
|
||||||
|
$scope.$apply();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// so we're currently in the outbox.
|
||||||
|
// if the currently selected mail is still among the pending mails, re-select it, since the object has changed.
|
||||||
|
// however, if the mail is NOT in the outbox anymore, select another pending mail
|
||||||
|
//
|
||||||
|
// this is a workaround due to the fact that the outbox loads pending messages from the indexedDB,
|
||||||
|
// where object identity is broken when you read an object twice, which happens upon the next retry
|
||||||
|
// to send the pending messages...
|
||||||
|
|
||||||
|
mail = _.findWhere(outbox.messages, {
|
||||||
|
id: $scope.state.mailList.selected.id
|
||||||
|
});
|
||||||
|
|
||||||
|
if (mail) {
|
||||||
|
// select the 'new old' mail
|
||||||
|
$scope.state.mailList.selected = mail;
|
||||||
|
} else {
|
||||||
|
if (outbox.messages.length) {
|
||||||
|
// there are more mails to show, select another one in the list
|
||||||
|
$scope.state.mailList.selected = outbox.messages[0];
|
||||||
|
} else {
|
||||||
|
// no mails to show, don't select anything...
|
||||||
|
$scope.state.mailList.selected = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1209,6 +1209,7 @@ define(function(require) {
|
|||||||
mail.body = err ? err.errMsg : decrypted;
|
mail.body = err ? err.errMsg : decrypted;
|
||||||
after();
|
after();
|
||||||
});
|
});
|
||||||
|
mail.encrypted = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user