From 557bb28cff3e3769b329fa373a5b3d44f083fc8c Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Wed, 6 Apr 2022 08:32:07 +0000 Subject: [PATCH] [FIX] mail: ensure that voice threshold is updated across tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, updating the voice activation threshold in one tab would not affect the other tabs as the localStorage was only read when discuss was initialized. This commit fixes this issue. task-2679234 closes odoo/odoo#88154 X-original-commit: 80c81c70787952eb4fdc4b81210bdf2893210e1a Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/user_setting.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/mail/static/src/models/user_setting.js b/addons/mail/static/src/models/user_setting.js index 565d0d2b8e8..99b63d67815 100644 --- a/addons/mail/static/src/models/user_setting.js +++ b/addons/mail/static/src/models/user_setting.js @@ -1,5 +1,7 @@ /** @odoo-module **/ +import { browser } from "@web/core/browser/browser"; + import { registerModel } from '@mail/model/model_core'; import { attr, many, one } from '@mail/model/model_field'; import { clear, insertAndReplace } from '@mail/model/model_field_command'; @@ -10,8 +12,10 @@ registerModel({ lifecycleHooks: { _created() { this._loadLocalSettings(); + browser.addEventListener('storage', this._onStorage); }, _willDelete() { + browser.removeEventListener('storage', this._onStorage); for (const timeout of Object.values(this.volumeSettingsTimeouts)) { this.messaging.browser.clearTimeout(timeout); } @@ -183,6 +187,16 @@ registerModel({ }); } }, + /** + * @private + * @param {Event} ev + */ + async _onStorage(ev) { + if (ev.key === 'mail_user_setting_voice_threshold') { + this.update({ voiceActivationThreshold: ev.newValue }); + await this.messaging.rtc.updateVoiceActivation(); + } + }, /** * @private */