Mail: Fix issues adding email account

- Et2Tree.refreshItem() wrong return type
This commit is contained in:
nathan 2024-10-09 09:43:39 -06:00
parent 64ce874f62
commit f654b4ee00
2 changed files with 30 additions and 12 deletions

View File

@ -509,7 +509,10 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
{
let item = this.getNode(_id);
// if the item does not exist in the tree yet no need to refresh
if(item == null) return
if(item == null)
{
return Promise.resolve();
}
return this.handleLazyLoading(item).then((result) => {
item.item = [...result.item]
this.requestUpdate("_selectOptions")
@ -1039,6 +1042,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
>
<sl-icon name="chevron-right" slot="expand-icon"></sl-icon>
<sl-icon name="chevron-down" slot="collapse-icon"></sl-icon>
<slot></slot>
${repeat(this._selectOptions, (o) => o.value, this._optionTemplate)}
</sl-tree>
`;

View File

@ -677,8 +677,19 @@ app.classes.mail = AppJS.extend(
break;
case 'add':
const current_id = tree.getValue();
// need to wait tree is refreshed: current and new id are there AND current folder is selected again
tree.refreshItem(0).then(() => {
tree._selectOptions.push({
id: "" + _id,
label: this.egw.lang("Loading..."),
selected: false,
loading: true,
lazy: true
});
tree.requestUpdate("_selectOptions");
tree.updateComplete.then(async () =>
{
// need to wait tree is refreshed: current and new id are there AND current folder is selected again
await tree.refreshItem(_id);
if (tree.getNode(_id) && tree.getNode(current_id))
{
if (!tree.getSelectedNode())
@ -689,16 +700,19 @@ app.classes.mail = AppJS.extend(
{
// open new account
// need to wait new folders are loaded AND current folder is selected again
tree.openItem(_id, true).then(() => {
if (tree.getNode(_id + '::INBOX')) {
if (!tree.getSelectedNode()) {
tree.reSelectItem(current_id);
} else {
this.mail_changeFolder(_id + '::INBOX', tree, current_id);
tree.reSelectItem(_id + '::INBOX');
}
await tree.openItem(_id, true);
if (tree.getNode(_id + '::INBOX'))
{
if (!tree.getSelectedNode())
{
tree.reSelectItem(current_id);
}
});
else
{
this.mail_changeFolder(_id + '::INBOX', tree, current_id);
tree.reSelectItem(_id + '::INBOX');
}
}
}
}
});