From e79fae20497375b0806ca8dabf7f3513b2f0e96d Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Mon, 23 Sep 2024 12:55:43 +0200 Subject: [PATCH] fixup! fix: refactor store Signed-off-by: Maksim Sukharev --- .../MediaSettings/MediaDevicesSpeakerTest.vue | 11 ++++++++--- src/stores/sounds.js | 8 ++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/MediaSettings/MediaDevicesSpeakerTest.vue b/src/components/MediaSettings/MediaDevicesSpeakerTest.vue index 1a189740d62..ab22794dd2b 100644 --- a/src/components/MediaSettings/MediaDevicesSpeakerTest.vue +++ b/src/components/MediaSettings/MediaDevicesSpeakerTest.vue @@ -76,10 +76,15 @@ export default { return } this.isPlayingTestSound = true - this.soundsStore.playAudio('wait') - this.soundsStore.audioObjects.wait.addEventListener('ended', () => { + try { + this.soundsStore.playAudio('wait') + this.soundsStore.audioObjects.wait.addEventListener('ended', () => { + this.isPlayingTestSound = false + }, { once: true }) + } catch (error) { + console.error(error) this.isPlayingTestSound = false - }, { once: true }) + } }, }, } diff --git a/src/stores/sounds.js b/src/stores/sounds.js index c08ca49a253..0f25089672f 100644 --- a/src/stores/sounds.js +++ b/src/stores/sounds.js @@ -13,11 +13,10 @@ import { generateFilePath } from '@nextcloud/router' import BrowserStorage from '../services/BrowserStorage.js' import { setPlaySounds } from '../services/settingsService.js' +const hasUserAccount = Boolean(getCurrentUser()?.uid) /** * Get play sounds option (from server for user or from browser storage for guest) - * @param {boolean} value whether sounds should be played */ -const hasUserAccount = Boolean(getCurrentUser()?.uid) const shouldPlaySounds = hasUserAccount ? loadState('spreed', 'play_sounds', false) : BrowserStorage.getItem('play_sounds') !== 'no' @@ -56,10 +55,7 @@ export const useSoundsStore = defineStore('sounds', { }, pauseAudio(key) { - if (!this.audioObjectsCreated) { - this.initAudioObjects() - } - this.audioObjects[key].pause() + this.audioObjects[key]?.pause() }, /**