From affb057a0cb77978acab0c7c4250e5d6ce4b9ee1 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Wed, 23 Aug 2023 14:57:05 +0200 Subject: [PATCH] webmail: fix case where tree of mailboxes wasn't displayed properly for example, when these mailboxes existed: "a", "a.b", "a/b", then "a.b" (. before / in ascii) prevented "a/b" from being displayed in the tree below "a". --- webmail/webmail.js | 9 +++++++++ webmail/webmail.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/webmail/webmail.js b/webmail/webmail.js index 68a28ec..ee7f586 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -3321,6 +3321,15 @@ const newMailboxlistView = (msglistView, requestNewView, updatePageTitle, setLoc else if (ai >= 0 && bi >= 0 && ai !== bi) { return ai < bi ? -1 : 1; } + const la = mbva.mailbox.Name.split('/'); + const lb = mbvb.mailbox.Name.split('/'); + let n = Math.min(la.length, lb.length); + for (let i = 0; i < n; i++) { + if (la[i] === lb[i]) { + continue; + } + return la[i] < lb[i] ? -1 : 1; + } return mbva.mailbox.Name < mbvb.mailbox.Name ? -1 : 1; }); let prevmailboxname = ''; diff --git a/webmail/webmail.ts b/webmail/webmail.ts index f5f0a4e..f49231f 100644 --- a/webmail/webmail.ts +++ b/webmail/webmail.ts @@ -3144,6 +3144,15 @@ const newMailboxlistView = (msglistView: MsglistView, requestNewView: requestNew } else if (ai >= 0 && bi >= 0 && ai !== bi) { return ai < bi ? -1 : 1 } + const la = mbva.mailbox.Name.split('/') + const lb = mbvb.mailbox.Name.split('/') + let n = Math.min(la.length, lb.length) + for (let i = 0; i < n; i++) { + if (la[i] === lb[i]) { + continue + } + return la[i] < lb[i] ? -1 : 1 + } return mbva.mailbox.Name < mbvb.mailbox.Name ? -1 : 1 })