[REF] mail, im_livechat: move "discuss.channel/last_interest_dt_changed"

To discuss folder.

Part of task-3265211

closes odoo/odoo#128593

Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit is contained in:
Sébastien Theys
2023-07-17 18:13:40 +02:00
parent a008feec69
commit b43f8c840e
3 changed files with 10 additions and 25 deletions
@@ -1,7 +1,6 @@
/* @odoo-module */
import { Messaging } from "@mail/core/common/messaging_service";
import { createLocalId } from "@mail/utils/common/misc";
import { patch } from "@web/core/utils/patch";
@@ -12,15 +11,6 @@ patch(Messaging.prototype, "im_livechat", {
this.store.discuss.livechat.isOpen = true;
}
},
_handleNotificationLastInterestDtChanged(notif) {
this._super(notif);
const channel = this.store.threads[createLocalId("discuss.channel", notif.payload.id)];
if (channel?.type === "livechat") {
this.threadService.sortChannels();
}
},
_handleNotificationRecordInsert(notif) {
this._super(notif);
const { "res.users.settings": settings } = notif.payload;
@@ -4,7 +4,6 @@ import { CannedResponse } from "@mail/core/common/canned_response_model";
import { LinkPreview } from "@mail/core/common/link_preview_model";
import { removeFromArray, removeFromArrayWithPredicate } from "@mail/utils/common/arrays";
import { cleanTerm } from "@mail/utils/common/format";
import { createLocalId } from "@mail/utils/common/misc";
import { markup, reactive } from "@odoo/owl";
@@ -288,9 +287,6 @@ export class Messaging {
});
}
break;
case "discuss.channel/last_interest_dt_changed":
this._handleNotificationLastInterestDtChanged(notif);
break;
case "ir.attachment/delete":
{
const { id: attachmentId, message: messageData } = notif.payload;
@@ -309,17 +305,6 @@ export class Messaging {
}
}
_handleNotificationLastInterestDtChanged(notif) {
const { id, last_interest_dt } = notif.payload;
const channel = this.store.threads[createLocalId("discuss.channel", id)];
if (channel) {
this.threadService.update(channel, { last_interest_dt });
}
if (["chat", "group"].includes(channel?.type)) {
this.threadService.sortChannels();
}
}
_handleNotificationRecordInsert(notif) {
if (notif.payload.Thread) {
this.threadService.insert(notif.payload.Thread);
@@ -47,6 +47,16 @@ export class DiscussCoreCommon {
);
}
});
this.busService.subscribe("discuss.channel/last_interest_dt_changed", (payload) => {
const { id, last_interest_dt } = payload;
const channel = this.store.threads[createLocalId("discuss.channel", id)];
if (channel) {
this.threadService.update(channel, { last_interest_dt });
if (channel.type !== "channel") {
this.threadService.sortChannels();
}
}
});
this.busService.subscribe("discuss.channel/leave", (payload) => {
const thread = this.threadService.insert({
...payload,