[FIX] mail: properly handle discuss active_id 'discuss.channel_'

Before this commit, when loading discuss app with
`active_id=discuss.channel_1` in URL, the discuss app did not
auto-select the conversation.

This happens because the code did not parse model and id part of
"discuss.channel_1": it split into `discuss.chann` and `l_1`,
instead of `discuss.channel` and `1`. This comes from splitting
the same way as legacy `mail.channel`, starts with 13 characters,
although there are now 16 characters in `discuss.channel`.

This commit fixes the issue by simplify the way the active thread
of discuss is deduced from active_id.

closes odoo/odoo#119559

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-04-25 15:20:49 +02:00
parent f4ea6d3226
commit cdf456ea00
2 changed files with 8 additions and 18 deletions
@@ -759,22 +759,14 @@ export const messagingService = {
start(env, services) {
// compute initial discuss thread if not on public page
if (!services["mail.store"].inPublicPage) {
let threadLocalId = createLocalId("mail.box", "inbox");
const activeId = services.router.current.hash.active_id;
if (typeof activeId === "number") {
threadLocalId = createLocalId("discuss.channel", activeId);
const activeId = services.router.current.hash.active_id ?? "mail.box_inbox";
let [model, id] =
typeof activeId === "number" ? ["discuss.channel", activeId] : activeId.split("_");
if (model === "mail.channel") {
// legacy format (sent in old emails, shared links, ...)
model = "discuss.channel";
}
if (typeof activeId === "string" && activeId.startsWith("mail.box_")) {
threadLocalId = createLocalId("mail.box", activeId.slice(9));
}
// legacy format (sent in old emails, shared links, ...)
if (typeof activeId === "string" && activeId.startsWith("mail.channel_")) {
threadLocalId = createLocalId("discuss.channel", parseInt(activeId.slice(13), 10));
}
if (typeof activeId === "string" && activeId.startsWith("discuss.channel_")) {
threadLocalId = createLocalId("discuss.channel", parseInt(activeId.slice(13), 10));
}
services["mail.store"].discuss.threadLocalId = threadLocalId;
services["mail.store"].discuss.threadLocalId = createLocalId(model, id);
}
const messaging = new Messaging(env, services);
messaging.initialize();
+1 -3
View File
@@ -155,9 +155,7 @@ export const storeService = {
if (!res.isSmall) {
res.discuss.activeTab = "all";
} else {
res.discuss.activeTab = res.discuss.threadLocalId
? res.threads[res.discuss.threadLocalId].type
: "all";
res.discuss.activeTab = res.threads[res.discuss.threadLocalId]?.type ?? "all";
}
});
return res;