feat(mail): allow to directly empty junk folder

Fixes #5224
This commit is contained in:
Francis Lachapelle
2021-11-02 16:54:36 -04:00
parent ab67e7d279
commit 6c56340ba5
6 changed files with 62 additions and 10 deletions
@@ -659,15 +659,16 @@
};
/**
* @function $emptyTrash
* @function $empty
* @memberof Mailbox.prototype
* @desc Empty the Trash folder.
* @returns a promise of the HTTP operation
*/
Mailbox.prototype.$emptyTrash = function() {
var _this = this;
Mailbox.prototype.$empty = function() {
var _this = this,
action = 'empty' + this.type[0].capitalize() + this.type.substring(1);
return Mailbox.$$resource.post(this.id, 'emptyTrash').then(function(data) {
return Mailbox.$$resource.post(this.id, action).then(function(data) {
// Remove all messages from the mailbox
_this.$messages = _this.$visibleMessages = [];
_this.uidsMap = {};
@@ -258,11 +258,19 @@
});
};
this.emptyJunkFolder = function() {
return this.emptyFolder(l('Junk folder emptied'));
};
this.emptyTrashFolder = function() {
this.folder.$emptyTrash().then(function() {
return this.emptyFolder(l('Trash emptied'));
};
this.emptyFolder = function(successMsg) {
this.folder.$empty().then(function() {
$mdToast.show(
$mdToast.simple()
.textContent(l('Trash emptied'))
.textContent(successMsg)
.position('top right')
.hideDelay(3000));
});