[FIX] discuss: prevent push-to-talk release spam on some devices

Before this commit, devices with the key-repeat feature turned on
would not work well with the push-to-talk feature.

This commit sets a minimum delay before a push-to-talk key is considered
released.

closes odoo/odoo#139396

X-original-commit: aced53322309898d060c082e3d009293123ffea0
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
TSO
2023-10-23 13:11:24 +00:00
committed by Alexandre Kühn
parent 0ff4fa07cf
commit fc573a8d8b
2 changed files with 7 additions and 8 deletions
@@ -41,7 +41,7 @@
<label class="d-flex align-items-center flex-wrap mw-100 cursor-pointer" title="Delay after releasing push-to-talk" aria-label="Delay after releasing push-to-talk">
<span class="me-2 text-truncate">Delay after releasing push-to-talk</span>
<div class="d-flex w-100">
<input class="flex-grow-2 form-range" type="range" min="1" max="2000" step="1" t-att-value="userSettings.voiceActiveDuration" t-on-change="onChangeDelay"/>
<input class="flex-grow-2 form-range" type="range" min="200" max="2000" step="1" t-att-value="userSettings.voiceActiveDuration" t-on-change="onChangeDelay"/>
</div>
</label>
</div>
@@ -189,13 +189,12 @@ export class Rtc {
) {
return;
}
if (!this.state.selfSession.isMute) {
this.soundEffectsService.play("push-to-talk-off", { volume: 0.3 });
}
this.state.pttReleaseTimeout = browser.setTimeout(
() => this.setTalking(false),
this.userSettingsService.voiceActiveDuration || 0
);
this.state.pttReleaseTimeout = browser.setTimeout(() => {
this.setTalking(false);
if (!this.state.selfSession?.isMute) {
this.soundEffectsService.play("push-to-talk-off", { volume: 0.3 });
}
}, Math.max(this.userSettingsService.voiceActiveDuration || 0, 200));
},
{ capture: true }
);