From 21aef5beb949efb17b5d51d2a1a7be9ff0bf1fd6 Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Tue, 18 Jul 2023 06:41:19 +0000 Subject: [PATCH] [FIX] mail: sets the push-to-talk key events of the call in capture mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the `keydown` and `keyup` events of the call feature were in bubble mode, which could prevent them from operating when some other listeners would prevent the propagation of the event. Since push-to-talk is supposed to always be usable, the listeners are now in capture mode. It was first made apparent with the addition of a `stopPropagation()` in the `chatWindow` here: https://github.com/odoo/odoo/pull/127638 closes odoo/odoo#128897 X-original-commit: 1466a6bc471ed583966e959b47f10bdc64837732 Signed-off-by: Didier Debondt (did) Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/discuss/call/common/call_settings.js | 4 ++-- addons/mail/static/src/discuss/call/common/rtc_service.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/discuss/call/common/call_settings.js b/addons/mail/static/src/discuss/call/common/call_settings.js index c5cde382f43..bc702a34eee 100644 --- a/addons/mail/static/src/discuss/call/common/call_settings.js +++ b/addons/mail/static/src/discuss/call/common/call_settings.js @@ -21,8 +21,8 @@ export class CallSettings extends Component { this.state = useState({ userDevices: [], }); - useExternalListener(browser, "keydown", this._onKeyDown); - useExternalListener(browser, "keyup", this._onKeyUp); + useExternalListener(browser, "keydown", this._onKeyDown, { capture: true }); + useExternalListener(browser, "keyup", this._onKeyUp, { capture: true }); onWillStart(async () => { if (!browser.navigator.mediaDevices) { // zxing-js: isMediaDevicesSuported or canEnumerateDevices is false. diff --git a/addons/mail/static/src/discuss/call/common/rtc_service.js b/addons/mail/static/src/discuss/call/common/rtc_service.js index 43e21214921..4cdec9b7443 100644 --- a/addons/mail/static/src/discuss/call/common/rtc_service.js +++ b/addons/mail/static/src/discuss/call/common/rtc_service.js @@ -217,7 +217,7 @@ export class Rtc { this.soundEffectsService.play("push-to-talk-on", { volume: 0.3 }); } this.setTalking(true); - }); + }, { capture: true }); browser.addEventListener("keyup", (ev) => { if ( !this.state.channel || @@ -234,7 +234,7 @@ export class Rtc { () => this.setTalking(false), this.userSettingsService.voiceActiveDuration || 0 ); - }); + }, { capture: true }); browser.addEventListener("pagehide", () => { if (this.state.channel) {