diff --git a/addons/mail/static/src/core/web/thread_service_patch.js b/addons/mail/static/src/core/web/thread_service_patch.js index f6edb33c841..fcd59ac561c 100644 --- a/addons/mail/static/src/core/web/thread_service_patch.js +++ b/addons/mail/static/src/core/web/thread_service_patch.js @@ -235,16 +235,16 @@ patch(ThreadService.prototype, { return Object.values(this.store.Thread.records) .filter((thread) => thread.model === "discuss.channel") .sort((a, b) => { - if (!a.lastInterestDateTime && !b.lastInterestDateTime) { - return 0; + if (a.lastInterestDateTime?.ts !== b.lastInterestDateTime?.ts) { + if (!b.lastInterestDateTime) { + return -1; + } + if (!a.lastInterestDateTime) { + return 1; + } + return b.lastInterestDateTime.ts - a.lastInterestDateTime.ts; } - if (a.lastInterestDateTime && !b.lastInterestDateTime) { - return -1; - } - if (!a.lastInterestDateTime && b.lastInterestDateTime) { - return 1; - } - return b.lastInterestDateTime.ts - a.lastInterestDateTime.ts; + return a.id - b.id; }); }, getNeedactionChannels() { diff --git a/addons/mail/static/tests/discuss/core/web/command_palette_tests.js b/addons/mail/static/tests/discuss/core/web/command_palette_tests.js index daa2b0e8dc3..a1a490d61fa 100644 --- a/addons/mail/static/tests/discuss/core/web/command_palette_tests.js +++ b/addons/mail/static/tests/discuss/core/web/command_palette_tests.js @@ -43,6 +43,8 @@ QUnit.test("open the chatWindow of a channel from the command palette", async () await insertText(".o_command_palette_search input", "#"); advanceTime(commandSetupRegistry.get("#").debounceDelay); await contains(".o_command", { count: 2 }); + await contains(".o_command", { text: "general", before: [".o_command", { text: "project" }] }); + await contains(".o_command.focused"); await click(".o_command.focused", { text: "general" }); await contains(".o-mail-ChatWindow", { text: "general" }); });