From b242900619701896c1d15fdde4811a37542cea26 Mon Sep 17 00:00:00 2001 From: Hristo Terezov Date: Tue, 23 Jul 2024 16:57:44 -0500 Subject: [PATCH] fix(push2talk): incorect state on release because a new audio track is beening created. (part 2) --- conference.js | 10 ++++++---- react/features/keyboard-shortcuts/actions.web.ts | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/conference.js b/conference.js index 4518c35b2c16..36079ef5ac3a 100644 --- a/conference.js +++ b/conference.js @@ -705,11 +705,13 @@ export default { /** * Simulates toolbar button click for audio mute. Used by shortcuts and API. + * * @param {boolean} mute true for mute and false for unmute. * @param {boolean} [showUI] when set to false will not display any error * dialogs in case of media permissions error. + * @returns {Promise} */ - muteAudio(mute, showUI = true) { + async muteAudio(mute, showUI = true) { const state = APP.store.getState(); if (!mute @@ -749,7 +751,8 @@ export default { }; APP.store.dispatch(gumPending([ MEDIA_TYPE.AUDIO ], IGUMPendingState.PENDING_UNMUTE)); - createLocalTracksF({ devices: [ 'audio' ] }) + + await createLocalTracksF({ devices: [ 'audio' ] }) .then(([ audioTrack ]) => audioTrack) .catch(error => { maybeShowErrorDialog(error); @@ -1277,8 +1280,7 @@ export default { return; } - APP.store.dispatch( - replaceLocalTrack(oldTrack, newTrack, room)) + APP.store.dispatch(replaceLocalTrack(oldTrack, newTrack, room)) .then(() => { this.updateAudioIconEnabled(); }) diff --git a/react/features/keyboard-shortcuts/actions.web.ts b/react/features/keyboard-shortcuts/actions.web.ts index 80763a1f4f6c..c8935dd96a9b 100644 --- a/react/features/keyboard-shortcuts/actions.web.ts +++ b/react/features/keyboard-shortcuts/actions.web.ts @@ -107,7 +107,8 @@ export const initKeyboardShortcuts = () => pttTimeout = window.setTimeout(() => { sendAnalytics(createShortcutEvent('push.to.talk', ACTION_SHORTCUT_RELEASED)); logger.log('Talk shortcut released'); - mutePromise = mutePromise.then(() => APP.conference.muteAudio(true)); + mutePromise = mutePromise.then(() => + APP.conference.muteAudio(true).catch(() => { /* nothing to be done */ })); }, pttDelay); } @@ -131,7 +132,8 @@ export const initKeyboardShortcuts = () => clearTimeout(pttTimeout); sendAnalytics(createShortcutEvent('push.to.talk', ACTION_SHORTCUT_PRESSED)); logger.log('Talk shortcut pressed'); - mutePromise = mutePromise.then(() => APP.conference.muteAudio(false)); + mutePromise = mutePromise.then(() => + APP.conference.muteAudio(false).catch(() => { /* nothing to be done */ })); } else if (key === 'ESCAPE') { focusedElement?.blur(); }