[FIX] im_livechat: fix message unread counter
Since [1], the way the message unread counter is computed has changed. The patch of the `im_livechat` module is not adapted properly. This commit fixes this issue. [1]: 6ebe033b00774ed8824d05f0adf9dae5f3654261 closes odoo/odoo#118581 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -51,7 +51,7 @@ patch(ThreadService.prototype, "im_livechat", {
|
||||
|
||||
getCounter(thread) {
|
||||
if (thread.type === "livechat") {
|
||||
return thread.message_needaction_counter;
|
||||
return thread.message_unread_counter;
|
||||
}
|
||||
return this._super(thread);
|
||||
},
|
||||
|
||||
@@ -449,3 +449,28 @@ QUnit.test("Clicking on unpin button unpins the channel", async (assert) => {
|
||||
await click(".o-mail-DiscussCategoryItem [title='Unpin Conversation']");
|
||||
assert.verifySteps(["You unpinned your conversation with Visitor 11"]);
|
||||
});
|
||||
|
||||
QUnit.test("Message unread counter", async (assert) => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "Harry" });
|
||||
const userId = pyEnv["res.users"].create({ name: "Harry", partner_id: partnerId });
|
||||
const channelId = pyEnv["mail.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,
|
||||
});
|
||||
const { env, openDiscuss } = await start();
|
||||
await openDiscuss();
|
||||
await afterNextRender(async () =>
|
||||
env.services.rpc("/mail/chat_post", {
|
||||
context: { mockedUserId: userId },
|
||||
message_content: "hu",
|
||||
uuid: pyEnv["mail.channel"].searchRead([["id", "=", channelId]])[0].uuid,
|
||||
})
|
||||
);
|
||||
assert.containsOnce($, ".o-mail-DiscussCategoryItem .badge:contains(1)");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user