mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-05 05:35:08 +00:00
feat(junk): add junk action on mail view
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
- (BOOL) notifyOnExternalModifications;
|
||||
|
||||
- (NSDictionary *) mailJunkSettings;
|
||||
- (NSString *) mailJunkIcon;
|
||||
|
||||
- (BOOL) createIdentitiesDisabled;
|
||||
|
||||
|
||||
@@ -481,6 +481,21 @@
|
||||
return [self objectForKey: @"SOGoMailJunkSettings"];
|
||||
}
|
||||
|
||||
- (NSString *) mailJunkIcon
|
||||
{
|
||||
NSArray *iconsList;
|
||||
NSString *icon;
|
||||
|
||||
iconsList = [NSArray arrayWithObjects: @"thumb_down", @"gpp_bad", nil];
|
||||
icon = [self objectForKey: @"mailJunkIcon"];
|
||||
if (([icon length] && ![iconsList containsObject:icon]) || ![icon length])
|
||||
{
|
||||
icon = @"thumb_down";
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
- (BOOL) createIdentitiesDisabled
|
||||
{
|
||||
return [self boolForKey: @"SOGoCreateIdentitiesDisabled"];
|
||||
|
||||
@@ -344,6 +344,9 @@ static SoProduct *preferencesProduct = nil;
|
||||
[[defaults source] setObject: [domainDefaults calendarJitsiRoomPrefix] forKey: @"SOGoCalendarJitsiRoomPrefix"];
|
||||
}
|
||||
|
||||
//Add the Junk Icon pref
|
||||
[[defaults source] setObject: [domainDefaults mailJunkIcon] forKey: @"mailJunkIcon"];
|
||||
|
||||
//
|
||||
// Default Contacts preferences
|
||||
//
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
<md-icon>delete</md-icon>
|
||||
</md-button>
|
||||
<md-button class="sg-icon-button" ng-click="mailbox.markOrUnMarkMessagesAsJunk()">
|
||||
<md-icon ng-hide="::mailbox.service.selectedFolder.type == 'junk'">thumb_down</md-icon>
|
||||
<md-icon ng-hide="::mailbox.service.selectedFolder.type == 'junk'">{{ mailbox.junkIcon}}</md-icon>
|
||||
<md-tooltip ng-hide="::mailbox.service.selectedFolder.type == 'junk'" md-direction="bottom"><var:string label:value="Junk"/></md-tooltip>
|
||||
<md-icon ng-hide="::mailbox.service.selectedFolder.type != 'junk'">thumb_up</md-icon>
|
||||
<md-tooltip ng-hide="::mailbox.service.selectedFolder.type != 'junk'" md-direction="bottom"><var:string label:value="Not junk"/></md-tooltip>
|
||||
|
||||
@@ -45,6 +45,14 @@
|
||||
<md-icon class="ng-animate-disabled" ng-switch-when="true" rsrc:md-svg-src="img/mark_email_unread.svg"><!-- mark as unread --></md-icon>
|
||||
<md-icon class="ng-animate-disabled" ng-switch-default="true" rsrc:md-svg-src="img/mark_email_read.svg"><!-- mark as read --></md-icon>
|
||||
</md-button>
|
||||
<md-button class="sg-icon-button" label:aria-label="Junk"
|
||||
ng-hide="::viewer.message.isDraft"
|
||||
ng-click="viewer.markOrUnMarkAsJunk()">
|
||||
<md-tooltip md-direction="bottom" ng-hide="::viewer.mailbox.type == 'junk'"><var:string label:value="Junk"/></md-tooltip>
|
||||
<md-tooltip md-direction="bottom" ng-show="::viewer.mailbox.type == 'junk'"><var:string label:value="Not junk"/></md-tooltip>
|
||||
<md-icon ng-hide="::viewer.mailbox.type == 'junk'">{{ viewer.junkIcon }}</md-icon>
|
||||
<md-icon ng-show="::viewer.mailbox.type == 'junk'">thumb_up</md-icon>
|
||||
</md-button>
|
||||
<md-button class="sg-icon-button"
|
||||
ng-hide="::viewer.message.isDraft"
|
||||
ng-click="viewer.reply($event)"
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -207,7 +207,7 @@
|
||||
}
|
||||
else if (this.type == 'junk') {
|
||||
this.$displayName = l('JunkFolderName');
|
||||
this.$icon = 'thumb_down';
|
||||
this.$icon = Mailbox.$Preferences.defaults.mailJunkIcon;
|
||||
}
|
||||
else if (this.type == 'templates') {
|
||||
this.$displayName = l('TemplatesFolderName');
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
this.allSelected = false;
|
||||
this.isLoadingMessage = false;
|
||||
this.nextAction = null;
|
||||
this.junkIcon = Preferences.defaults.mailJunkIcon;
|
||||
|
||||
if (!Mailbox.$virtualMode)
|
||||
this.selectedFolder.getLabels(); // fetch labels from server
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
this.$showDetailedRecipients = this.$alwaysShowDetailedRecipients;
|
||||
this.showRawSource = false;
|
||||
this.mailInDeletion = -1;
|
||||
this.junkIcon = Preferences.defaults.mailJunkIcon;
|
||||
|
||||
_registerHotkeys(hotkeys);
|
||||
|
||||
@@ -319,10 +320,60 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Select either the next or previous message once the current message
|
||||
// has been removed from the mailbox (deleted or moved), then close the
|
||||
// popup if any.
|
||||
function _selectNextMessage(mailbox, state, index) {
|
||||
var nextMessage, previousMessage,
|
||||
nextIndex = index,
|
||||
$timeout = vm.service.$timeout;
|
||||
|
||||
if (angular.isDefined(state)) {
|
||||
if (index > 0) {
|
||||
nextIndex -= 1;
|
||||
nextMessage = mailbox.getItemAtIndex(nextIndex);
|
||||
}
|
||||
if (index < mailbox.getLength())
|
||||
previousMessage = mailbox.getItemAtIndex(index);
|
||||
|
||||
if (nextMessage) {
|
||||
if (nextMessage.isread && previousMessage && !previousMessage.isread) {
|
||||
nextIndex = index;
|
||||
nextMessage = previousMessage;
|
||||
}
|
||||
}
|
||||
else if (previousMessage) {
|
||||
nextIndex = index;
|
||||
nextMessage = previousMessage;
|
||||
}
|
||||
|
||||
try {
|
||||
if (nextMessage && $mdMedia(sgConstant['gt-md'])) {
|
||||
if (Mailbox.$virtualMode)
|
||||
state.go('mail.account.virtualMailbox.message', {mailboxId: encodeUriFilter(nextMessage.$mailbox.path), messageId: nextMessage.uid});
|
||||
else
|
||||
state.go('mail.account.mailbox.message', {messageId: nextMessage.uid});
|
||||
$timeout(function() {
|
||||
if (nextIndex < mailbox.$topIndex)
|
||||
mailbox.$topIndex = nextIndex;
|
||||
else if (nextIndex > mailbox.$lastVisibleIndex)
|
||||
mailbox.$topIndex = nextIndex - (mailbox.$lastVisibleIndex - mailbox.$topIndex);
|
||||
});
|
||||
}
|
||||
else {
|
||||
state.go('mail.account.mailbox').then(function() {
|
||||
delete mailbox.$selectedMessage;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {}
|
||||
}
|
||||
vm.closePopup();
|
||||
}
|
||||
|
||||
this.deleteMessage = function() {
|
||||
var mailbox, message, state, nextMessage, previousMessage,
|
||||
parentCtrls = $parentControllers(),
|
||||
$timeout = this.service.$timeout;
|
||||
var mailbox, message, state,
|
||||
parentCtrls = $parentControllers();
|
||||
|
||||
if (parentCtrls.messageCtrl) {
|
||||
mailbox = parentCtrls.mailboxCtrl.selectedFolder;
|
||||
@@ -340,52 +391,9 @@
|
||||
vm.mailInDeletion = message.uid;
|
||||
|
||||
function _success(index) {
|
||||
var nextIndex = index;
|
||||
// Remove message object from scope
|
||||
message = null;
|
||||
if (angular.isDefined(state)) {
|
||||
// Select either the next or previous message
|
||||
if (index > 0) {
|
||||
nextIndex -= 1;
|
||||
nextMessage = mailbox.getItemAtIndex(nextIndex);
|
||||
}
|
||||
if (index < mailbox.getLength())
|
||||
previousMessage = mailbox.getItemAtIndex(index);
|
||||
|
||||
if (nextMessage) {
|
||||
if (nextMessage.isread && previousMessage && !previousMessage.isread) {
|
||||
nextIndex = index;
|
||||
nextMessage = previousMessage;
|
||||
}
|
||||
}
|
||||
else if (previousMessage) {
|
||||
nextIndex = index;
|
||||
nextMessage = previousMessage;
|
||||
}
|
||||
|
||||
try {
|
||||
if (nextMessage && $mdMedia(sgConstant['gt-md'])) {
|
||||
if (Mailbox.$virtualMode)
|
||||
state.go('mail.account.virtualMailbox.message', {mailboxId: encodeUriFilter(nextMessage.$mailbox.path), messageId: nextMessage.uid});
|
||||
else
|
||||
state.go('mail.account.mailbox.message', {messageId: nextMessage.uid});
|
||||
$timeout(function() {
|
||||
if (nextIndex < mailbox.$topIndex)
|
||||
mailbox.$topIndex = nextIndex;
|
||||
else if (nextIndex > mailbox.$lastVisibleIndex)
|
||||
mailbox.$topIndex = nextIndex - (mailbox.$lastVisibleIndex - mailbox.$topIndex);
|
||||
});
|
||||
}
|
||||
else {
|
||||
state.go('mail.account.mailbox').then(function() {
|
||||
message = null;
|
||||
delete mailbox.$selectedMessage;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {}
|
||||
}
|
||||
vm.closePopup();
|
||||
_selectNextMessage(mailbox, state, index);
|
||||
}
|
||||
|
||||
mailbox.$deleteMessages([message]).then(_success, function(response) {
|
||||
@@ -407,6 +415,39 @@
|
||||
});
|
||||
};
|
||||
|
||||
this.markOrUnMarkAsJunk = function() {
|
||||
var mailbox, message, state, account, dstFolder,
|
||||
parentCtrls = $parentControllers();
|
||||
|
||||
if (parentCtrls.messageCtrl) {
|
||||
mailbox = parentCtrls.mailboxCtrl.selectedFolder;
|
||||
message = parentCtrls.messageCtrl.message;
|
||||
state = parentCtrls.messageCtrl.$state;
|
||||
account = parentCtrls.messageCtrl.account;
|
||||
}
|
||||
else {
|
||||
mailbox = stateMailbox;
|
||||
message = stateMessage;
|
||||
state = $state;
|
||||
account = stateAccount;
|
||||
}
|
||||
if (Mailbox.$virtualMode) {
|
||||
mailbox = Mailbox.selectedFolder; // the VirtualMailbox instance
|
||||
}
|
||||
|
||||
if (mailbox.type == 'junk')
|
||||
dstFolder = '/' + account.id + '/folderINBOX';
|
||||
else
|
||||
dstFolder = '/' + account.$getMailboxByType('junk').id;
|
||||
|
||||
mailbox.$markOrUnMarkMessagesAsJunk([message]).then(function() {
|
||||
mailbox.$moveMessages([message], dstFolder).then(function(index) {
|
||||
message = null;
|
||||
_selectNextMessage(mailbox, state, index);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function _showMailEditor($event, message) {
|
||||
if (_messageDialog() === null) {
|
||||
var onCompleteDeferred = $q.defer();
|
||||
|
||||
@@ -11,10 +11,9 @@ $icon-badge-size: 2 * $baseline-grid;
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url('../fonts/MaterialIcons-Regular.eot'); /* For IE6-8 */
|
||||
src: local('Material Icons'),
|
||||
local('MaterialIcons-Regular'),
|
||||
url('../fonts/MaterialIcons-Regular.woff2') format('woff2'),
|
||||
/* No local() sources: always use the bundled font so an outdated
|
||||
Material Icons font installed on the OS can't shadow it. */
|
||||
src: url('../fonts/MaterialIcons-Regular.woff2') format('woff2'),
|
||||
url('../fonts/MaterialIcons-Regular.woff') format('woff'),
|
||||
url('../fonts/MaterialIcons-Regular.ttf') format('truetype');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user