diff --git a/addons/mail/static/src/core/common/suggestion_service.js b/addons/mail/static/src/core/common/suggestion_service.js index 2a4a8a3e5db..32d2dc2ff3c 100644 --- a/addons/mail/static/src/core/common/suggestion_service.js +++ b/addons/mail/static/src/core/common/suggestion_service.js @@ -208,8 +208,9 @@ export class SuggestionService { } } if (thread) { - const isFollower1 = thread.followers.some((follower) => follower.partner === p1); - const isFollower2 = thread.followers.some((follower) => follower.partner === p2); + const followerList = [...thread.followers]; + const isFollower1 = followerList.some((follower) => follower.partner === p1); + const isFollower2 = followerList.some((follower) => follower.partner === p2); if (isFollower1 && !isFollower2) { return -1; } diff --git a/addons/mail/static/src/core/common/thread_model.js b/addons/mail/static/src/core/common/thread_model.js index b7e2732204a..a4697fcf301 100644 --- a/addons/mail/static/src/core/common/thread_model.js +++ b/addons/mail/static/src/core/common/thread_model.js @@ -51,8 +51,8 @@ export class Thread { customName; /** @type {string} */ description; - /** @type {import("@mail/core/common/follower_model").Follower[]} */ - followers = []; + /** @type {Set} */ + followers = new Set(); isAdmin = false; loadOlder = false; loadNewer = false; @@ -256,7 +256,12 @@ export class Thread { * @returns {import("@mail/core/common/follower_model").Follower} */ get followerOfSelf() { - return this.followers.find((f) => f.partner === this._store.self); + for (const follower of this.followers) { + if (follower.partner === this._store.self) { + return follower; + } + } + return undefined; } get imgUrl() { diff --git a/addons/mail/static/src/core/web/chatter.js b/addons/mail/static/src/core/web/chatter.js index 3b3427f4a2c..7418feddb4b 100644 --- a/addons/mail/static/src/core/web/chatter.js +++ b/addons/mail/static/src/core/web/chatter.js @@ -201,7 +201,7 @@ export class Chatter extends Component { * @returns {string} */ get toRecipientsText() { - const followers = this.state.thread.followers.slice(0, 5).map(({ partner }) => { + const followers = [...this.state.thread.followers].slice(0, 5).map(({ partner }) => { if (partner === this.store.self) { return `me`; } @@ -213,7 +213,7 @@ export class Chatter extends Component { this.store.env.services["user"].lang?.replace("_", "-"), { type: "unit" } ); - if (this.state.thread.followers.length > 5) { + if (this.state.thread.followers.size > 5) { followers.push("…"); } return markup(formatter.format(followers)); diff --git a/addons/mail/static/src/core/web/chatter.xml b/addons/mail/static/src/core/web/chatter.xml index c9403fec8d4..34e2a9ebe30 100644 --- a/addons/mail/static/src/core/web/chatter.xml +++ b/addons/mail/static/src/core/web/chatter.xml @@ -35,17 +35,17 @@ - + Add Followers -