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
@@ -3,6 +3,7 @@
/* Icon's label */
"Create" = "Create";
"Empty Trash" = "Empty Trash";
"Empty Junk Folder" = "Empty Junk Folder";
"Delete" = "Delete";
"Expunge" = "Expunge";
"Forward" = "Forward";
@@ -73,8 +74,13 @@
"An error occured while communicating with the mail server" = "An error occured while communicating with the mail server";
/* Mailbox actions */
/* Compact Folder success message */
"Folder compacted" = "Folder compacted";
/* Empty Junk Folder success message */
"Junk folder emptied" = "Junk folder emptied";
/* Empty Trash success message */
"Trash emptied" = "Trash emptied";
@@ -387,6 +393,12 @@
"Send Anyway" = "Send Anyway";
"Error while saving the draft" = "Error while saving the draft";
/* Error when emptying trash */
"Unable to empty the trash folder." = "Unable to empty the trash folder.";
/* Error when emptying junk folder */
"Unable to empty the junk folder." = "Unable to empty the junk folder.";
/* Error when uploading a file attachment */
"Error while uploading the file \"%{0}\":" = "Error while uploading the file \"%{0}\":";
"There is an active file upload. Closing the window will interrupt it." = "There is an active file upload. Closing the window will interrupt it.";
+3 -1
View File
@@ -1,6 +1,6 @@
/* UIxMailFolderActions.h - this file is part of SOGo
*
* Copyright (C) 2007-2016 Inverse inc.
* Copyright (C) 2007-2021 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,7 +33,9 @@
- (WOResponse *) batchDeleteAction;
- (WOResponse *) saveMessagesAction;
- (WOResponse *) expungeAction;
- (WOResponse *) emptyJunkAction;
- (WOResponse *) emptyTrashAction;
- (WOResponse *) emptySpecialFolderAction: (NSString *) folderType;
- (WOResponse *) subscribeAction;
- (WOResponse *) unsubscribeAction;
- (id <WOActionResults>) getLabelsAction;
+15 -3
View File
@@ -31,6 +31,7 @@
#import <Mailer/SOGoMailAccount.h>
#import <Mailer/SOGoMailFolder.h>
#import <Mailer/SOGoTrashFolder.h>
#import <SOGo/NSArray+Utilities.h>
@@ -876,15 +877,25 @@
return response;
}
- (WOResponse *) emptyJunkAction
{
return [self emptySpecialFolderAction: @"junk"];
}
- (WOResponse *) emptyTrashAction
{
return [self emptySpecialFolderAction: @"trash"];
}
- (WOResponse *) emptySpecialFolderAction: (NSString *) folderType
{
NSException *error;
SOGoTrashFolder *co;
SOGoSpecialMailFolder *co;
SOGoMailAccount *account;
NSEnumerator *subfolders;
WOResponse *response;
NGImap4Connection *connection;
NSString *currentName;
NSString *currentName, *errorMsg;
NSDictionary *data;
id quota;
@@ -909,7 +920,8 @@
}
if (error)
{
data = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to empty the trash folder." inContext: context]
errorMsg = [NSString stringWithFormat: @"Unable to empty the %@ folder.", folderType];
data = [NSDictionary dictionaryWithObject: [self labelForKey: errorMsg inContext: context]
forKey: @"message"];
response = [self responseWithStatus: 500 andJSONRepresentation: data];
}
+17
View File
@@ -161,6 +161,23 @@
};
};
SOGoJunkFolder = {
/* just a new toolbar, other things come from SOGoMailFolder */
slots = {
toolbar = {
protectedBy = "View";
value = "SOGoMailFolder.toolbar";
};
};
methods = {
emptyJunk = {
protectedBy = "View";
actionClass = "UIxMailFolderActions";
actionName = "emptyJunk";
};
};
};
SOGoTrashFolder = {
/* just a new toolbar, other things come from SOGoMailFolder */
slots = {
@@ -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));
});