Skip to content

Commit

Permalink
fix(mail(js)): reset mailboxes state when leaving global search
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Oct 21, 2021
1 parent ab38b1d commit 642db85
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
38 changes: 19 additions & 19 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,25 +869,6 @@
});
};

/**
* @function $reset
* @memberof Mailbox.prototype
* @desc Reset the original state the mailbox's data.
*/
Mailbox.prototype.$reset = function(options) {
var _this = this;
angular.forEach(this.$shadowData, function(value, key) {
delete _this[key];
});
angular.extend(this, this.$shadowData);
this.$shadowData = this.$omit();
if (options && options.filter) {
this.$messages = [];
this.$visibleMessages = [];
delete this.$syncToken;
}
};

/**
* @function $move
* @memberof Mailbox.prototype
Expand Down Expand Up @@ -935,6 +916,25 @@
return this.$account.$newMailbox(path, name);
};

/**
* @function $reset
* @memberof Mailbox.prototype
* @desc Reset the original state the mailbox's data.
*/
Mailbox.prototype.$reset = function(options) {
var _this = this;
angular.forEach(this.$shadowData, function(value, key) {
delete _this[key];
});
angular.extend(this, this.$shadowData);
this.$shadowData = this.$omit();
if (options && options.filter) {
this.$messages = [];
this.$visibleMessages = [];
delete this.$syncToken;
}
};

/**
* @function $omit
* @memberof Mailbox.prototype
Expand Down
11 changes: 4 additions & 7 deletions UI/WebServerResources/js/Mailer/MailboxController.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
_.forEach(hotkeys, function(key) {
sgHotkeys.deregisterHotkey(key);
});
if (vm.mode.search) {
vm.mode.search = false;
vm.selectedFolder.$reset({ filter: true });
}
});

// Update window's title with unseen messages count of selected mailbox
Expand All @@ -53,13 +57,6 @@
title += ' | ' + defaultWindowTitle;
$window.document.title = title;
});

$scope.$on('$destroy', function() {
if (vm.mode.search) {
vm.mode.search = false;
vm.selectedFolder.$reset({ filter: true });
}
});
};

function _registerHotkeys(keys) {
Expand Down
11 changes: 11 additions & 0 deletions UI/WebServerResources/js/Mailer/VirtualMailbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,15 @@
return true;
};

/**
* @function $reset
* @memberof VirtualMailbox.prototype
* @desc Reset the original state all mailboxes data.
*/
VirtualMailbox.prototype.$reset = function(options) {
_.forEach(this.$mailboxes, function(mailbox) {
mailbox.$reset(options);
});
};

})();
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@
if (this.editMode || this.mailbox == Mailbox.selectedFolder || this.mailbox.isNoSelect())
return;
Mailbox.$virtualPath = false;
Mailbox.$virtualMode = false;
if (Mailbox.$virtualMode) {
Mailbox.$virtualMode = false;
Mailbox.selectedFolder.$reset({ filter: true });
}
this.accountController.selectFolder(this);
if ($event) {
$state.go('mail.account.mailbox', {
Expand Down

0 comments on commit 642db85

Please sign in to comment.