(js) Simplify Mailbox.prototype.$emptyTrash

This commit is contained in:
Francis Lachapelle 2015-08-18 21:16:05 -04:00
parent e5b0596bc9
commit 83fee27ca8

View file

@ -413,13 +413,9 @@
* @returns a promise of the HTTP operation * @returns a promise of the HTTP operation
*/ */
Mailbox.prototype.$emptyTrash = function() { Mailbox.prototype.$emptyTrash = function() {
var _this = this, var _this = this;
deferred = Mailbox.$q.defer(),
promise;
promise = Mailbox.$$resource.post(this.id, 'emptyTrash'); return Mailbox.$$resource.post(this.id, 'emptyTrash').then(function() {
promise.then(function() {
// Remove all messages from the mailbox // Remove all messages from the mailbox
_this.$messages = []; _this.$messages = [];
_this.uidsMap = {}; _this.uidsMap = {};
@ -428,11 +424,7 @@
// If we had any submailboxes, lets do a refresh of the mailboxes list // If we had any submailboxes, lets do a refresh of the mailboxes list
if (angular.isDefined(_this.children) && _this.children.length) if (angular.isDefined(_this.children) && _this.children.length)
_this.$account.$getMailboxes({reload: true}); _this.$account.$getMailboxes({reload: true});
}, function(data, status) {
deferred.reject(data);
}); });
return deferred.promise;
}; };
/** /**