mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-31 16:14:53 +00:00
fix(mail(js)): update list of labels when adding one to a message
This commit is contained in:
@@ -706,13 +706,14 @@
|
||||
* @desc Fetch the list of labels associated to the mailbox. Use the cached value if available.
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Mailbox.prototype.getLabels = function() {
|
||||
Mailbox.prototype.getLabels = function(options) {
|
||||
var _this = this;
|
||||
|
||||
if (this.$labels)
|
||||
return this.$labels;
|
||||
if (this.$labels && !(options && options.reload))
|
||||
return Mailbox.$q.when(this.$labels);
|
||||
|
||||
this.$filteredLabels = {};
|
||||
if (angular.isUndefined(this.$filteredLabels))
|
||||
this.$filteredLabels = {};
|
||||
return Mailbox.$$resource.fetch(this.id, 'labels').then(function(data) {
|
||||
_this.$labels = data;
|
||||
return _this.$labels;
|
||||
|
||||
@@ -496,7 +496,18 @@
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.addTag = function(tag) {
|
||||
return this.$addOrRemoveTag('add', tag);
|
||||
var _this = this,
|
||||
_tag = tag.replace(/^_\$/, '$');
|
||||
return this.$mailbox.getLabels().then(function(labels) {
|
||||
var reload = !_.find(labels, function(label) {
|
||||
return label.imapName == _tag;
|
||||
});
|
||||
return _this.$addOrRemoveTag('add', tag).then(function() {
|
||||
if (reload)
|
||||
// Update the list of labels for the mailbox
|
||||
_this.$mailbox.getLabels({reload: true});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user