(js) Restore immediate deletion of messages

This commit is contained in:
Francis Lachapelle
2016-11-01 10:35:00 -04:00
parent 67f566ec9d
commit 5c7147cccc
4 changed files with 28 additions and 6 deletions

View File

@@ -676,11 +676,14 @@
* @desc Delete multiple messages from mailbox.
* @return a promise of the HTTP operation
*/
Mailbox.prototype.$deleteMessages = function(messages) {
var _this = this, uids;
Mailbox.prototype.$deleteMessages = function(messages, options) {
var _this = this, uids, data;
uids = _.map(messages, 'uid');
return Mailbox.$$resource.post(this.id, 'batchDelete', {uids: uids})
data = { uids: uids };
if (options) angular.extend(data, options);
return Mailbox.$$resource.post(this.id, 'batchDelete', data)
.then(function(data) {
// Update inbox quota
if (data.quotas)

View File

@@ -268,9 +268,9 @@
return [vm.selectedFolder];
}
// Unselect current message and cleverly load the next message.
// This function must not be called in virtual mode.
function _unselectMessage(message, index) {
// Unselect current message and cleverly load the next message.
// This function must not be called in virtual mode.
var nextMessage, previousMessage, nextIndex = index;
vm.mode.multiple = vm.selectedFolder.$selectedCount();
if (message) {
@@ -327,6 +327,24 @@
// In normal mode, we immediately unselect the selected message.
_unselectMessage(deleteSelectedMessage, index);
}
}, function(response) {
messageDialog = Dialog.confirm(l('Warning'),
l('The messages could not be moved to the trash folder. Would you like to delete them immediately?'),
{ ok: l('Delete') })
.then(function() {
vm.selectedFolder.$deleteMessages(selectedMessages, { withoutTrash: true }).then(function(index) {
if (Mailbox.$virtualMode) {
// When performing an advanced search, we refresh the view if the selected message
// was deleted, but only once all promises have completed.
if (deleteSelectedMessage)
$state.go('mail.account.virtualMailbox');
}
else {
// In normal mode, we immediately unselect the selected message.
_unselectMessage(deleteSelectedMessage, index);
}
});
});
});
})
.finally(function() {