mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-08 06:48:51 +00:00
fix(mail(js)): update list of labels when adding one to a message
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
sg-false-value="0"> <var:string label:value="Show flagged messages only"/></sg-checkmark>
|
||||
</md-menu-item>
|
||||
<md-menu-divider> <!-- divider --></md-menu-divider>
|
||||
<md-menu-item ng-repeat="label in ::mailbox.selectedFolder.$labels track by label.imapName">
|
||||
<md-menu-item ng-repeat="label in mailbox.selectedFolder.$labels track by label.imapName">
|
||||
<sg-checkmark
|
||||
ng-change="mailbox.selectedFolder.$filter(mailbox.service.$query)"
|
||||
ng-model="mailbox.selectedFolder.$filteredLabels[label.imapName]"
|
||||
|
||||
@@ -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