From 378ea11c6ced04e94d8dbf92c4f0660866d866c2 Mon Sep 17 00:00:00 2001 From: milan Date: Thu, 26 Sep 2024 16:07:39 +0200 Subject: [PATCH] fix click on new mail account does not display unseen badges --ticket #99041 --- api/js/etemplate/Et2Tree/Et2Tree.ts | 16 ++++++++++++++-- mail/inc/class.mail_ui.inc.php | 2 +- mail/js/app.js | 8 +++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index e7162ecac9..c0e05676f6 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -83,6 +83,9 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin //does not work because it would need to be run on the shadow root //@query("sl-tree-item[selected]") selected: SlTreeItem; + //the trees lazy-loading promise, so we can externally do additional stuff after it resolves + private lazyLoading: Promise; + /** * get the first selected node using attributes on the shadow root elements */ @@ -178,7 +181,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin // Check if top level should be autoloaded if(this.autoloading && !this._selectOptions?.length) { - this.handleLazyLoading({item: this._selectOptions}).then((results) => + this.lazyLoading = this.handleLazyLoading({item: this._selectOptions}).then((results) => { this._selectOptions = results?.item ?? []; this._initCurrent() @@ -850,6 +853,15 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin this.widget_object.getObjectById(id).iface.triggerEvent(typeMap[event.type], event); } + protected async finishedLazyLoading() + { + await this.lazyLoading; + let result = this.lazyLoading + return result + } + + + /** * Overridable, add style * @returns {TemplateResult<1>} @@ -923,7 +935,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin // No need for this to bubble up, we'll handle it (otherwise the parent leaf will load too) event.stopPropagation(); - this.handleLazyLoading(selectOption).then((result) => { + this.lazyLoading = this.handleLazyLoading(selectOption).then((result) => { // TODO: We already have the right option in context. Look into this.getNode(), find out why it's there. It doesn't do a deep search. const parentNode = selectOption ?? this.getNode(selectOption.id) ?? this.optionSearch(selectOption.id, this._selectOptions, 'id', 'item'); parentNode.item = [...result.item] diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index d2bbd2d180..06c956b5a9 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -4140,7 +4140,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2); foreach ($_folder as $_folderName) { list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); - if (is_numeric($profileID)) + if (is_numeric($profileID)) //things like mail::xxx will be ignored { if ($profileID != $this->mail_bo->profileID) continue; // only current connection if ($folderName) diff --git a/mail/js/app.js b/mail/js/app.js index 42e91de04d..5d8c52777d 100755 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1533,10 +1533,8 @@ app.classes.mail = AppJS.extend( { this.mail_refreshQuotaDisplay(); } - // TODO the two lines below are not working yet. - //var no =tree_wdg.getSelectedItem(); - //tree_wdg.focusItem(no.id); - } catch(e) { } // ignore the error; maybe the template is not loaded yet + } catch(e) { + } // ignore the error; maybe the template is not loaded yet }, /** @@ -2390,7 +2388,7 @@ app.classes.mail = AppJS.extend( this.unlock_tree(); },this)) .sendRequest(true); - _widget.updateComplete.then (() => { + _widget.finishedLazyLoading().then (() => { this.mail_changeFolder(folder+"::INBOX", _widget, ''); _widget.reSelectItem(folder+"::INBOX") });