[FIX] mail, im_livechat: show livechats in livechat tab in mobile

Before this commit, livechats in mobile were shown in the "Chat"
tab in both discuss app and messaging menu. This is alright, but
there's a dedicated tab for "Livechat", which was empty as a result.

The intended showing in mobile is to keep livechat away from "Chat",
and instead populate the "Livechat" filter.

Task-3430253

closes odoo/odoo#128934

X-original-commit: cf4b72582bbb52c7cd4bc17733f4dbbc84f9b321
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-07-19 01:54:28 +02:00
parent 355250d062
commit 8ed39b9244
3 changed files with 26 additions and 2 deletions
@@ -11,7 +11,10 @@ patch(MessagingMenu.prototype, "im_livechat", {
*/
tabToThreadType(tab) {
const threadTypes = this._super(tab);
if (tab === "chat") {
if (tab === "chat" && !this.ui.isSmall) {
threadTypes.push("livechat");
}
if (tab === "livechat") {
threadTypes.push("livechat");
}
return threadTypes;
@@ -1,6 +1,7 @@
/* @odoo-module */
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { patchUiSize } from "@mail/../tests/helpers/patch_ui_size";
QUnit.module("messaging menu (patch)");
@@ -24,3 +25,23 @@ QUnit.test('livechats should be in "chat" filter', async (assert) => {
assert.hasClass($(".o-mail-MessagingMenu button:contains(Chat)"), "fw-bolder");
assert.containsOnce($, ".o-mail-NotificationItem:contains(Visitor 11)");
});
QUnit.test('livechats should be in "livechat" tab in mobile', async (assert) => {
patchUiSize({ height: 360, width: 640 });
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
anonymous_name: "Visitor 11",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: pyEnv.publicPartnerId }],
],
channel_type: "livechat",
livechat_operator_id: pyEnv.currentPartnerId,
});
await start();
await click(".o_menu_systray i[aria-label='Messages']");
await click("button:contains(Livechat)");
assert.containsOnce($, ".o-mail-NotificationItem:contains(Visitor 11)");
await click("button:contains(Chat)");
assert.containsNone($, ".o-mail-NotificationItem:contains(Visitor 11)");
});
@@ -24,7 +24,7 @@
<button class="btn btn-link" t-att-class="store.discuss.activeTab === 'channel' ? 'fw-bolder' : 'text-muted'" type="button" role="tab" t-on-click="() => store.discuss.activeTab = 'channel'">Channels</button>
</t>
</div>
<div t-if="!env.inDiscussApp or ['chat', 'channel'].includes(store.discuss.activeTab)" class="list-group-flush d-flex flex-column overflow-auto flex-grow-1">
<div t-if="!env.inDiscussApp or !['all', 'mailbox'].includes(store.discuss.activeTab)" class="list-group-flush d-flex flex-column overflow-auto flex-grow-1">
<div class="d-flex justify-content-center py-4 px-2 text-muted" t-if="!hasPreviews">
No conversation yet...
</div>