Skip to content

Commit

Permalink
fix(mail): Fix issue where unread counter is invalid when whanging fo…
Browse files Browse the repository at this point in the history
…lder. Fixes #6001.
  • Loading branch information
WoodySlum committed Aug 20, 2024
1 parent a24d59d commit 1f6bbc1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,17 @@
*/
Mailbox.prototype.$reset = function(options) {
var _this = this;
var account;
angular.forEach(this.$shadowData, function(value, key) {
delete _this[key];
});
account = Object.assign({}, _this.$account)
angular.extend(this, this.$shadowData);
this.$shadowData = this.$omit();
this.account = account;
if (options && options.unseenCount) {
this.unseenCount = options.unseenCount;
}
if (options && options.filter) {
this.$messages = [];
this.$visibleMessages = [];
Expand Down
23 changes: 15 additions & 8 deletions UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
/**
* @ngInject
*/
sgMailboxListItemController.$inject = ['$scope', '$rootScope', '$element', '$state', '$timeout', '$mdToast', '$mdPanel', '$mdMedia', '$mdSidenav', 'sgConstant', 'Dialog', 'Mailbox', 'encodeUriFilter'];
function sgMailboxListItemController($scope, $rootScope, $element, $state, $timeout, $mdToast, $mdPanel, $mdMedia, $mdSidenav, sgConstant, Dialog, Mailbox, encodeUriFilter) {
sgMailboxListItemController.$inject = ['$scope', '$rootScope', '$element', '$state', '$timeout', '$mdToast', '$mdPanel', '$mdMedia', '$mdSidenav', 'sgConstant', 'Dialog', 'Mailbox', 'encodeUriFilter', '$window', 'Account'];
function sgMailboxListItemController($scope, $rootScope, $element, $state, $timeout, $mdToast, $mdPanel, $mdMedia, $mdSidenav, sgConstant, Dialog, Mailbox, encodeUriFilter, $window, Account) {
var $ctrl = this;


Expand Down Expand Up @@ -87,13 +87,20 @@
if (this.editMode || this.mailbox == Mailbox.selectedFolder || this.mailbox.isNoSelect())
return;

this.mailbox.setHighlightWords([]);
if (Mailbox.$virtualMode) {
Mailbox.$virtualMode = false;
Mailbox.$virtualPath = false;
Mailbox.selectedFolder.$reset({ filter: true });
this.mailbox.setHighlightWords([]);

if (Mailbox.selectedFolder) {
if (Mailbox.$virtualMode) {
Mailbox.$virtualMode = false;
Mailbox.$virtualPath = false;
$rootScope.$broadcast('resetMailAdvancedSearchPanel'); // Reset advanced search panel (broadcast event to MailboxesController)
if (Mailbox.selectedFolder.$mailboxes && Mailbox.selectedFolder.$mailboxes.length > 0) {
Mailbox.selectedFolder.$reset({ filter: true, unseenCount: Mailbox.selectedFolder.$mailboxes[0].unseenCount });
}
} else {
Mailbox.selectedFolder.$reset({ filter: true, unseenCount: Mailbox.selectedFolder.unseenCount });
}
}
$rootScope.$broadcast('resetMailAdvancedSearchPanel'); // Reset advanced search panel (broadcast event to MailboxesController)

this.accountController.selectFolder(this);
if ($event) {
Expand Down

0 comments on commit 1f6bbc1

Please sign in to comment.