[FIX] mail: Mailbox is half loaded on mobile
Before this commit on mobile when you come to odoo from a notification url like: https://my_domain/web#action=mail.action_discuss&active_id=1&menu_id=93 a traceback occurs on mobile discuss wasn't loaded correctly and the content didn't appear. With this commit, it's open the related discuss thread. It's also ensure the return to the chat tab when you close a chat and the return to the channel tab when you close a channel conversation. We also ensure the loading of the inbox items when you navigating on the mobile discuss button. Steps to reproduce: 1. Open a chat from a mobile notification 2. A traceback occurs opw-2310319 closes odoo/odoo#58431 X-original-commit: 8ca5024bef246c93bbb7522d77aca4c4ba7a33b4 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -1246,6 +1246,28 @@ QUnit.test('load single message from channel initially', async function (assert)
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('open channel from active_id as channel id', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data['mail.channel'].records.push({ id: 20 });
|
||||
await this.start({
|
||||
discuss: {
|
||||
context: {
|
||||
active_id: 20,
|
||||
},
|
||||
}
|
||||
});
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`
|
||||
.o_Discuss_thread[data-thread-local-id="${
|
||||
this.env.models['mail.thread'].findFromIdentifyingData({ id: 20, model: 'mail.channel' }).localId
|
||||
}"]
|
||||
`,
|
||||
"should have channel with ID 20 open in Discuss when providing active_id 20"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('basic rendering of message', async function (assert) {
|
||||
// AKU TODO: should be in message-only tests
|
||||
assert.expect(13);
|
||||
|
||||
+32
@@ -91,6 +91,38 @@ QUnit.test('select another mailbox', async function (assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('auto-select "Inbox" when discuss had channel as active thread', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
this.data['mail.channel'].records.push({ id: 20 });
|
||||
await this.start({
|
||||
discuss: {
|
||||
context: {
|
||||
active_id: 20,
|
||||
},
|
||||
}
|
||||
});
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_MobileMessagingNavbar_tab[data-tab-id="channel"]'),
|
||||
'o-active',
|
||||
"'channel' tab should be active initially when loading discuss with channel id as active_id"
|
||||
);
|
||||
|
||||
await afterNextRender(() => document.querySelector('.o_MobileMessagingNavbar_tab[data-tab-id="mailbox"]').click());
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_MobileMessagingNavbar_tab[data-tab-id="mailbox"]'),
|
||||
'o-active',
|
||||
"'mailbox' tab should be selected after click on mailbox tab"
|
||||
);
|
||||
assert.hasClass(
|
||||
document.querySelector(`.o_DiscussMobileMailboxSelection_button[data-mailbox-local-id="${
|
||||
this.env.messaging.inbox.localId
|
||||
}"]`),
|
||||
'o-active',
|
||||
"'Inbox' mailbox should be auto-selected after click on mailbox tab"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,7 +151,9 @@ function factory(dependencies) {
|
||||
* is not yet initialized.
|
||||
*/
|
||||
openInitThread() {
|
||||
const [model, id] = this.initActiveId.split('_');
|
||||
const [model, id] = typeof this.initActiveId === 'number'
|
||||
? ['mail.channel', this.initActiveId]
|
||||
: this.initActiveId.split('_');
|
||||
const thread = this.env.models['mail.thread'].findFromIdentifyingData({
|
||||
id: model !== 'mail.box' ? Number(id) : id,
|
||||
model,
|
||||
@@ -160,6 +162,9 @@ function factory(dependencies) {
|
||||
return;
|
||||
}
|
||||
thread.open();
|
||||
if (this.env.messaging.device.isMobile && thread.channel_type) {
|
||||
this.update({ activeMobileNavbarTabId: thread.channel_type });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,6 +329,18 @@ function factory(dependencies) {
|
||||
*/
|
||||
_computeThread() {
|
||||
let thread = this.thread;
|
||||
if (this.env.messaging &&
|
||||
this.env.messaging.inbox &&
|
||||
this.env.messaging.device.isMobile &&
|
||||
this.activeMobileNavbarTabId === 'mailbox' &&
|
||||
this.initActiveId !== 'mail.box_inbox' &&
|
||||
!thread
|
||||
) {
|
||||
// After loading Discuss from an arbitrary tab other then 'mailbox',
|
||||
// switching to 'mailbox' requires to also set its inner-tab ;
|
||||
// by default the 'inbox'.
|
||||
return [['replace', this.env.messaging.inbox]];
|
||||
}
|
||||
if (!thread || !thread.isPinned) {
|
||||
return [['unlink']];
|
||||
}
|
||||
@@ -396,7 +413,9 @@ function factory(dependencies) {
|
||||
* Formatted init thread on opening discuss for the first time,
|
||||
* when no active thread is defined. Useful to set a thread to
|
||||
* open without knowing its local id in advance.
|
||||
* format: <threadModel>_<threadId>
|
||||
* Support two formats:
|
||||
* {string} <threadModel>_<threadId>
|
||||
* {int} <channelId> with default model of 'mail.channel'
|
||||
*/
|
||||
initActiveId: attr({
|
||||
default: 'mail.box_inbox',
|
||||
@@ -450,6 +469,9 @@ function factory(dependencies) {
|
||||
messaging: one2one('mail.messaging', {
|
||||
inverse: 'discuss',
|
||||
}),
|
||||
messagingInbox: many2one('mail.thread', {
|
||||
related: 'messaging.inbox',
|
||||
}),
|
||||
renamingThreads: one2many('mail.thread'),
|
||||
/**
|
||||
* The message that is currently selected as being replied to in Inbox.
|
||||
@@ -497,8 +519,13 @@ function factory(dependencies) {
|
||||
thread: many2one('mail.thread', {
|
||||
compute: '_computeThread',
|
||||
dependencies: [
|
||||
'activeMobileNavbarTabId',
|
||||
'deviceIsMobile',
|
||||
'isThreadPinned',
|
||||
'messaging',
|
||||
'messagingInbox',
|
||||
'thread',
|
||||
'threadModel',
|
||||
],
|
||||
}),
|
||||
threadId: attr({
|
||||
|
||||
Reference in New Issue
Block a user