From 6f12d0ad428a2f038fcbc50600796941e3f3f981 Mon Sep 17 00:00:00 2001 From: TSO Date: Thu, 25 Jan 2024 09:58:19 +0100 Subject: [PATCH] [FIX] discuss: fix slider values in call settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds text values for the call settings sliders. * Replaces `onChange` events with `onInput` events so that the values respect the position of the sliders. * Debounces some functions to handle the increased amount of calls due to the swap to the `onInput` listener. * Changes the default value of `voiceActiveDuration` from `0` to `200` to match the minimum value of the input. closes odoo/odoo#151028 Signed-off-by: Sébastien Theys (seb) --- addons/mail/models/res_users_settings.py | 2 +- .../src/core/common/user_settings_service.js | 14 +++++++----- .../src/discuss/call/common/call_settings.xml | 22 +++++++++++-------- .../src/discuss/call/common/rtc_service.js | 9 ++++---- .../tests/test_performance.py | 2 +- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/addons/mail/models/res_users_settings.py b/addons/mail/models/res_users_settings.py index 7501e992795..1ea66cd8bfc 100644 --- a/addons/mail/models/res_users_settings.py +++ b/addons/mail/models/res_users_settings.py @@ -13,7 +13,7 @@ class ResUsersSettings(models.Model): # RTC push_to_talk_key = fields.Char(string="Push-To-Talk shortcut", help="String formatted to represent a key with modifiers following this pattern: shift.ctrl.alt.key, e.g: truthy.1.true.b") use_push_to_talk = fields.Boolean(string="Use the push to talk feature", default=False) - voice_active_duration = fields.Integer(string="Duration of voice activity in ms", help="How long the audio broadcast will remain active after passing the volume threshold") + voice_active_duration = fields.Integer(string="Duration of voice activity in ms", default=200, help="How long the audio broadcast will remain active after passing the volume threshold") volume_settings_ids = fields.One2many('res.users.settings.volumes', 'user_setting_id', string="Volumes of other partners") @api.model diff --git a/addons/mail/static/src/core/common/user_settings_service.js b/addons/mail/static/src/core/common/user_settings_service.js index 84e898584af..d3ca85dca70 100644 --- a/addons/mail/static/src/core/common/user_settings_service.js +++ b/addons/mail/static/src/core/common/user_settings_service.js @@ -2,6 +2,7 @@ import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; +import { debounce } from "@web/core/utils/timing"; export class UserSettings { id; @@ -13,6 +14,12 @@ export class UserSettings { constructor(env, services) { this.orm = services.orm; this.store = services["mail.store"]; + this.saveVoiceThresholdDebounce = debounce(() => { + browser.localStorage.setItem( + "mail_user_setting_voice_threshold", + this.voiceActivationThreshold.toString() + ); + }, 2000); this.hasCanvasFilterSupport = typeof document.createElement("canvas").getContext("2d").filter !== "undefined"; this._loadLocalSettings(); @@ -48,7 +55,7 @@ export class UserSettings { logRtc = false; pushToTalkKey; usePushToTalk = false; - voiceActiveDuration = 0; + voiceActiveDuration = 200; useBlur = false; volumeSettingsTimeouts = new Map(); /** @@ -145,10 +152,7 @@ export class UserSettings { */ setThresholdValue(voiceActivationThreshold) { this.voiceActivationThreshold = voiceActivationThreshold; - browser.localStorage.setItem( - "mail_user_setting_voice_threshold", - voiceActivationThreshold.toString() - ); + this.saveVoiceThresholdDebounce(); } // methods diff --git a/addons/mail/static/src/discuss/call/common/call_settings.xml b/addons/mail/static/src/discuss/call/common/call_settings.xml index a2ba4fb0b1a..9eb8b0b7815 100644 --- a/addons/mail/static/src/discuss/call/common/call_settings.xml +++ b/addons/mail/static/src/discuss/call/common/call_settings.xml @@ -40,8 +40,9 @@