[IMP] mail: Move lastInterestDateTime to a getter

Part-of: odoo/odoo#115945
This commit is contained in:
Didier (did)
2023-03-20 20:14:46 +01:00
committed by Alexandre Kühn
parent 70b165a1db
commit 580042a2f5
2 changed files with 10 additions and 5 deletions
@@ -85,6 +85,8 @@ export class Thread {
suggestedRecipients = [];
hasLoadingFailed = false;
canPostOnReadonly;
/** @type {String} */
last_interest_dt;
constructor(store, data) {
Object.assign(this, {
@@ -387,6 +389,13 @@ export class Thread {
return Object.values(this.rtcSessions).filter((session) => session.videoStream).length;
}
get lastInterestDateTime() {
if (!this.last_interest_dt) {
return undefined;
}
return luxon.DateTime.fromISO(new Date(this.last_interest_dt).toISOString());
}
/**
*
* @param {import("@mail/core/persona_model").Persona} persona
@@ -481,17 +481,13 @@ export class ThreadService {
"name",
"state",
"group_based_subscription",
"last_interest_dt",
]);
if (thread.model === "mail.channel" && serverData.channel) {
thread.channel = assignDefined(thread.channel ?? {}, serverData.channel);
}
thread.memberCount = serverData.channel?.memberCount ?? thread.memberCount;
if (serverData.last_interest_dt) {
thread.lastInterestDateTime = luxon.DateTime.fromISO(
new Date(serverData.last_interest_dt).toISOString()
);
}
if (serverData.channel && "serverMessageUnreadCounter" in serverData.channel) {
thread.serverMessageUnreadCounter = serverData.channel.serverMessageUnreadCounter;
}