[WO-163] make pending mails visible in offline mode

This commit is contained in:
Felix Hammerl 2014-01-19 17:03:04 +01:00
parent 798b68cc7e
commit cb8ffe6f7b
3 changed files with 40 additions and 2 deletions

View File

@ -252,7 +252,6 @@ define(function(require) {
}
function sendEncrypted(email) {
removeFromPendingMails(email);
self._emailDao.sendEncrypted({
email: email
}, function(err) {
@ -267,6 +266,9 @@ define(function(require) {
return;
}
// the email has been sent, remove from pending mails
removeFromPendingMails(email);
// fire sent notification
self._onSent(email);

View File

@ -39,15 +39,50 @@ define(function(require) {
};
$scope.onOutboxUpdate = function(err, count) {
var outbox, mail;
if (err) {
$scope.onError(err);
return;
}
var outbox = _.findWhere($scope.account.folders, {
outbox = _.findWhere($scope.account.folders, {
type: 'Outbox'
});
// update the outbox mail 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();
};

View File

@ -1209,6 +1209,7 @@ define(function(require) {
mail.body = err ? err.errMsg : decrypted;
after();
});
mail.encrypted = true;
});
});