diff options
| author | Sébastien Theys <seb@odoo.com> | 2021-01-18 16:49:01 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-01-18 16:59:02 +0000 |
| commit | e995f03a9a55280b1e9173223cdfa619ae164cc3 (patch) | |
| tree | 3aefcd4e4621f11cc971a652d7ed6f01a70765c0 /addons/mail/static/src/models/messaging_notification_handler | |
| parent | 20d6efa817a4d839777c81d403bb8770807e784a (diff) | |
[FIX] mail, im_livechat, snailmail: use findFromIdentifyingData
find is O(n) and findFromIdentifyingData is O(1)
task-2440693
closes odoo/odoo#64712
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/messaging_notification_handler')
| -rw-r--r-- | addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js index 93d30e9de8b..f497fa420e6 100644 --- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js @@ -516,7 +516,7 @@ function factory(dependencies) { _handleNotificationPartnerDeletion({ message_ids }) { const moderationMailbox = this.env.messaging.moderation; for (const id of message_ids) { - const message = this.env.models['mail.message'].find(message => message.id === id); + const message = this.env.models['mail.message'].findFromIdentifyingData({ id }); if (message) { if ( message.moderation_status === 'pending_moderation' && @@ -569,7 +569,7 @@ function factory(dependencies) { // Furthermore, server should not send back all message_ids marked as read // but something like last read message_id or something like that. // (just imagine you mark 1000 messages as read ... ) - const message = this.env.models['mail.message'].find(m => m.id === message_id); + const message = this.env.models['mail.message'].findFromIdentifyingData({ id: message_id }); if (message) { message.update({ isNeedaction: false, @@ -582,10 +582,10 @@ function factory(dependencies) { let channels; if (channel_ids) { channels = channel_ids - .map(id => this.env.models['mail.thread'].find(thread => - thread.id === id && - thread.model === 'mail.channel' - )) + .map(id => this.env.models['mail.thread'].findFromIdentifyingData({ + id, + model: 'mail.channel', + })) .filter(thread => !!thread); } else { // flux specific: channel_ids unset means "mark all as read" @@ -628,9 +628,9 @@ function factory(dependencies) { _handleNotificationPartnerToggleStar({ message_ids = [], starred }) { const starredMailbox = this.env.messaging.starred; for (const messageId of message_ids) { - const message = this.env.models['mail.message'].find(message => - message.id === messageId - ); + const message = this.env.models['mail.message'].findFromIdentifyingData({ + id: messageId, + }); if (!message) { continue; } @@ -673,10 +673,10 @@ function factory(dependencies) { * @param {integer} channelId */ _handleNotificationPartnerUnsubscribe(channelId) { - const channel = this.env.models['mail.thread'].find(thread => - thread.id === channelId && - thread.model === 'mail.channel' - ); + const channel = this.env.models['mail.thread'].findFromIdentifyingData({ + id: channelId, + model: 'mail.channel', + }); if (!channel) { return; } |
