From abb909b5c404d1cc534f2d6e53f9a19f67dcaf2d Mon Sep 17 00:00:00 2001 From: ralf Date: Fri, 10 Mar 2023 11:52:45 +0100 Subject: [PATCH] open newly created accounts directly --- mail/js/app.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mail/js/app.js b/mail/js/app.js index e0f80dac91..cdea52bf64 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -671,7 +671,37 @@ app.classes.mail = AppJS.extend( } break; case 'add': + const current_id = tree.getValue(); tree.refreshItem(0); // refresh root + // ToDo: tree.refreshItem() and openItem() should return a promise + // need to wait tree is refreshed: current and new id are there AND current folder is selected again + const interval = window.setInterval(() => { + if (tree.getNode(_id) && tree.getNode(current_id)) + { + if (!tree.getSelectedNode()) + { + tree.reSelectItem(current_id); + } + else + { + window.clearInterval(interval); + // open new account + tree.openItem(_id, true); + // need to wait new folders are loaded AND current folder is selected again + const open_interval = window.setInterval(() => { + if (tree.getNode(_id + '::INBOX')) { + if (!tree.getSelectedNode()) { + tree.reSelectItem(current_id); + } else { + window.clearInterval(open_interval); + this.mail_changeFolder(_id + '::INBOX', tree, current_id); + tree.reSelectItem(_id + '::INBOX'); + } + } + }, 200); + } + } + }, 200); break; default: // null }