Skip to content

Commit

Permalink
fix(audio): Watch sound set changes and load new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanziness committed Sep 15, 2024
1 parent 444c557 commit 1004e38
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions platforms/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export function useWeb () {
}
})

watch(() => settingsStore.audio.soundSet, (newSoundSet) => {
loadSoundSet(newSoundSet)
})

eventsStore.$subscribe(() => {
if (eventsStore.lastEvent !== null && eventsStore.lastEvent._event === EventType.NOTIFICATIONS_ENABLED && window.Notification && window.Notification.permission === 'default') {
window.Notification.requestPermission().then((newNotificationPermission) => {
Expand Down Expand Up @@ -75,7 +79,7 @@ export function useWeb () {

// check if timer is already running
if (scheduleStore.timerState === 1) {
loadSoundSet()
loadSoundSet(settingsStore.audio.soundSet)
}

// Check Visibility and register in store
Expand Down Expand Up @@ -118,7 +122,7 @@ export function useWeb () {

state.currentSoundSet = setName
} catch (err) {
// console.warn(err)
console.warn(err)
}
}

Expand All @@ -129,7 +133,7 @@ export function useWeb () {
const playSound = (key: keyof typeof state.sounds) => {
// load sound set if not already loaded
if (!state.currentSoundSet) {
loadSoundSet()
loadSoundSet(settingsStore.audio.soundSet)
}

if (state.sounds[key] !== null && settingsStore.permissions.audio) {
Expand Down

0 comments on commit 1004e38

Please sign in to comment.