From eb77f591975e388af7a3699196c3550f8d95d405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 21 Feb 2022 15:15:06 +0000 Subject: [PATCH] [IMP] mail: turn "Rtc/pushToTalkTimeout" into fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2734101 closes odoo/odoo#85036 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/rtc.js | 32 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/addons/mail/static/src/models/rtc.js b/addons/mail/static/src/models/rtc.js index ce9c0bfeb35..97847f38898 100644 --- a/addons/mail/static/src/models/rtc.js +++ b/addons/mail/static/src/models/rtc.js @@ -26,11 +26,6 @@ registerModel({ identifyingFields: ['messaging'], lifecycleHooks: { _created() { - /** - * timeoutId for the push to talk release delay. - */ - this._pushToTalkTimeoutId = undefined; - browser.addEventListener('keydown', this._onKeyDown); browser.addEventListener('keyup', this._onKeyUp); // Disconnects the RTC session if the page is closed or reloaded. @@ -1145,9 +1140,7 @@ registerModel({ if (this.messaging.userSetting.rtcConfigurationMenu.isRegisteringKey) { return; } - if (this._pushToTalkTimeoutId) { - browser.clearTimeout(this._pushToTalkTimeoutId); - } + this.messaging.browser.clearTimeout(this.pushToTalkTimeout); if (!this.currentRtcSession.isTalking) { this.messaging.soundEffects.pushToTalkOn.play(); this._setSoundBroadcast(true); @@ -1170,12 +1163,19 @@ registerModel({ if (!this.currentRtcSession.isMute) { this.messaging.soundEffects.pushToTalkOff.play(); } - this._pushToTalkTimeoutId = browser.setTimeout( - () => { - this._setSoundBroadcast(false); - }, - this.messaging.userSetting.voiceActiveDuration || 0, - ); + this.update({ + pushToTalkTimeout: this.messaging.browser.setTimeout( + this._onPushToTalkTimeout, + this.messaging.userSetting.voiceActiveDuration, + ), + }); + }, + /** + * @private + */ + _onPushToTalkTimeout() { + this.update({ pushToTalkTimeout: clear() }); + this._setSoundBroadcast(false); }, /** * @private @@ -1293,6 +1293,10 @@ registerModel({ pingInterval: attr({ compute: '_computePingInterval', }), + /** + * timeoutId for the push to talk release delay. + */ + pushToTalkTimeout: attr(), /** * How long to wait before considering a connection as needing recovery in ms. */