Skip to content

Commit

Permalink
fixup! fix: refactor store
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Sep 23, 2024
1 parent 8ea4f69 commit e79fae2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/components/MediaSettings/MediaDevicesSpeakerTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
},
},
}
Expand Down
8 changes: 2 additions & 6 deletions src/stores/sounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -56,10 +55,7 @@ export const useSoundsStore = defineStore('sounds', {
},

pauseAudio(key) {
if (!this.audioObjectsCreated) {
this.initAudioObjects()
}
this.audioObjects[key].pause()
this.audioObjects[key]?.pause()
},

/**
Expand Down

0 comments on commit e79fae2

Please sign in to comment.