mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-22 03:45:25 +00:00
feat(mail): delay or disable automatic mark message as read
Fixes #1585
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px"><g><rect fill="none" height="24" width="24" x="0"/><path d="M12,19c0-3.87,3.13-7,7-7c1.08,0,2.09,0.25,3,0.68V6c0-1.1-0.9-2-2-2H4C2.9,4,2,4.9,2,6v12c0,1.1,0.9,2,2,2h8.08 C12.03,19.67,12,19.34,12,19z M4,6l8,5l8-5v2l-8,5L4,8V6z M17.34,22l-3.54-3.54l1.41-1.41l2.12,2.12l4.24-4.24L23,16.34L17.34,22z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 429 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px"><g><rect fill="none" height="24" width="24"/><path d="M22,8.98V18c0,1.1-0.9,2-2,2H4c-1.1,0-2-0.9-2-2V6c0-1.1,0.9-2,2-2h10.1C14.04,4.32,14,4.66,14,5 c0,1.48,0.65,2.79,1.67,3.71L12,11L4,6v2l8,5l5.3-3.32C17.84,9.88,18.4,10,19,10C20.13,10,21.16,9.61,22,8.98z M16,5 c0,1.66,1.34,3,3,3s3-1.34,3-3s-1.34-3-3-3S16,3.34,16,5z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 451 B |
@@ -132,6 +132,7 @@
|
||||
_this.flags.splice(i, 1,'_' + flag);
|
||||
}
|
||||
});
|
||||
this.isread = !!this.isread;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -540,6 +541,31 @@
|
||||
return Message.$$resource.post(this.$mailbox.$id(), 'addOrRemoveLabel', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function toggleRead
|
||||
* @memberof Message.prototype
|
||||
* @desc Toggle message unseen status
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.toggleRead = function() {
|
||||
var _this = this;
|
||||
|
||||
if (this.isread)
|
||||
return Message.$$resource.fetch(this.$absolutePath(), 'markMessageUnread').then(function() {
|
||||
Message.$timeout(function() {
|
||||
_this.isread = false;
|
||||
_this.$mailbox.unseenCount++;
|
||||
});
|
||||
});
|
||||
else
|
||||
return Message.$$resource.fetch(this.$absolutePath(), 'markMessageRead').then(function() {
|
||||
Message.$timeout(function() {
|
||||
_this.isread = true;
|
||||
_this.$mailbox.unseenCount--;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $imipAction
|
||||
* @memberof Message.prototype
|
||||
@@ -664,13 +690,16 @@
|
||||
var _this = this, futureMessageData;
|
||||
|
||||
if (options && options.useCache && this.$futureMessageData) {
|
||||
// The message has already been fetched.
|
||||
if (!this.isread) {
|
||||
Message.$$resource.fetch(this.$absolutePath(), 'markMessageRead').then(function() {
|
||||
Message.$timeout(function() {
|
||||
_this.isread = true;
|
||||
_this.$mailbox.unseenCount--;
|
||||
});
|
||||
});
|
||||
if (Message.$Preferences.defaults.SOGoMailAutoMarkAsReadDelay > -1)
|
||||
// Automatically mark message as read
|
||||
_this.$markAsReadPromise = Message.$timeout(function() {
|
||||
Message.$$resource.fetch(_this.$absolutePath(), 'markMessageRead').then(function() {
|
||||
_this.isread = true;
|
||||
_this.$mailbox.unseenCount--;
|
||||
});
|
||||
}, Message.$Preferences.defaults.SOGoMailAutoMarkAsReadDelay * 1000);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -865,7 +894,18 @@
|
||||
// Resolve and expose the promise
|
||||
this.$futureMessageData = futureMessageData.then(function(data) {
|
||||
// Calling $timeout will force Angular to refresh the view
|
||||
if (_this.isread === 0) {
|
||||
if (!data.isRead) {
|
||||
if (Message.$Preferences.defaults.SOGoMailAutoMarkAsReadDelay > -1)
|
||||
// Automatically mark message as read
|
||||
_this.$markAsReadPromise = Message.$timeout(function() {
|
||||
Message.$$resource.fetch(_this.$absolutePath(), 'markMessageRead').then(function() {
|
||||
_this.isread = true;
|
||||
_this.$mailbox.unseenCount--;
|
||||
});
|
||||
}, Message.$Preferences.defaults.SOGoMailAutoMarkAsReadDelay * 1000);
|
||||
}
|
||||
else if (!_this.isread) {
|
||||
// Message as already been marked read on the server
|
||||
_this.isread = true;
|
||||
_this.$mailbox.unseenCount--;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@
|
||||
_.forEach(hotkeys, function(key) {
|
||||
sgHotkeys.deregisterHotkey(key);
|
||||
});
|
||||
// Cancel automatic mark as read
|
||||
if (vm.message.$markAsReadPromise)
|
||||
vm.service.$timeout.cancel(vm.message.$markAsReadPromise);
|
||||
});
|
||||
|
||||
}; // $onInit
|
||||
|
||||
@@ -53,6 +53,13 @@
|
||||
if (data.SOGoRememberLastModule)
|
||||
data.SOGoLoginModule = "Last";
|
||||
|
||||
data.SOGoMailAutoMarkAsReadDelay = parseInt(data.SOGoMailAutoMarkAsReadDelay) || 0;
|
||||
data.SOGoMailAutoMarkAsReadEnabled = (data.SOGoMailAutoMarkAsReadDelay >= 0);
|
||||
if (data.SOGoMailAutoMarkAsReadDelay > 0)
|
||||
data.SOGoMailAutoMarkAsReadMode = 'delay';
|
||||
else
|
||||
data.SOGoMailAutoMarkAsReadMode = 'immediate';
|
||||
|
||||
// Mail editor autosave is a number of minutes or 0 if disabled
|
||||
data.SOGoMailAutoSave = parseInt(data.SOGoMailAutoSave) || 0;
|
||||
|
||||
@@ -724,6 +731,15 @@
|
||||
// Don't push locale definition
|
||||
delete preferences.defaults.locale;
|
||||
|
||||
if (preferences.defaults.SOGoMailAutoMarkAsReadEnabled) {
|
||||
if (preferences.defaults.SOGoMailAutoMarkAsReadMode == 'immediate')
|
||||
preferences.defaults.SOGoMailAutoMarkAsReadDelay = 0;
|
||||
} else {
|
||||
preferences.defaults.SOGoMailAutoMarkAsReadDelay = -1;
|
||||
}
|
||||
delete preferences.defaults.SOGoMailAutoMarkAsReadEnabled;
|
||||
delete preferences.defaults.SOGoMailAutoMarkAsReadMode;
|
||||
|
||||
// Merge back mail labels keys and values
|
||||
preferences.defaults.SOGoMailLabelsColors = {};
|
||||
_.forEach(preferences.defaults.SOGoMailLabelsColorsKeys, function(key, i) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
$mdConstant.KEY_CODE.COMMA,
|
||||
$mdConstant.KEY_CODE.SEMICOLON
|
||||
];
|
||||
this.mailAutoMarkAsReadDelay = Preferences.defaults.SOGoMailAutoMarkAsReadEnabled ? Preferences.defaults.SOGoMailAutoMarkAsReadDelay : 5;
|
||||
|
||||
// Set alternate avatar in User service
|
||||
if (Preferences.defaults.SOGoAlternateAvatar)
|
||||
@@ -107,6 +108,10 @@
|
||||
form.$setDirty();
|
||||
};
|
||||
|
||||
this.onMailAutoMarkAsReadDelay = function() {
|
||||
this.preferences.defaults.SOGoMailAutoMarkAsReadDelay = this.mailAutoMarkAsReadDelay;
|
||||
};
|
||||
|
||||
this.addMailAccount = function(ev, form) {
|
||||
var account, index;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user