fix: pop sound not saved and played when marking tasks done
This commit is contained in:
parent
553fd54f78
commit
c06cc6ad7a
3 changed files with 13 additions and 8 deletions
|
@ -104,11 +104,12 @@ export default {
|
||||||
async toggleTaskDone(task) {
|
async toggleTaskDone(task) {
|
||||||
this.loadingInternal = true
|
this.loadingInternal = true
|
||||||
try {
|
try {
|
||||||
|
const done = !task.done
|
||||||
await this.$store.dispatch('tasks/update', {
|
await this.$store.dispatch('tasks/update', {
|
||||||
...task,
|
...task,
|
||||||
done: !task.done,
|
done,
|
||||||
})
|
})
|
||||||
if (task.done) {
|
if (done) {
|
||||||
playPop()
|
playPop()
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -3,11 +3,15 @@ import popSoundFile from '@/assets/audio/pop.mp3'
|
||||||
export const playSoundWhenDoneKey = 'playSoundWhenTaskDone'
|
export const playSoundWhenDoneKey = 'playSoundWhenTaskDone'
|
||||||
|
|
||||||
export function playPop() {
|
export function playPop() {
|
||||||
const enabled = Boolean(localStorage.getItem(playSoundWhenDoneKey))
|
const enabled = localStorage.getItem(playSoundWhenDoneKey) === 'true'
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playPopSound()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function playPopSound() {
|
||||||
const popSound = new Audio(popSoundFile)
|
const popSound = new Audio(popSoundFile)
|
||||||
popSound.play()
|
popSound.play()
|
||||||
}
|
}
|
|
@ -135,7 +135,7 @@
|
||||||
import {computed, watch, ref} from 'vue'
|
import {computed, watch, ref} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import {playSoundWhenDoneKey, playPop} from '@/helpers/playPop'
|
import {playSoundWhenDoneKey, playPopSound} from '@/helpers/playPop'
|
||||||
import {availableLanguages} from '@/i18n'
|
import {availableLanguages} from '@/i18n'
|
||||||
import {getQuickAddMagicMode, setQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
import {getQuickAddMagicMode, setQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
||||||
import {PrefixMode} from '@/modules/parseTaskText'
|
import {PrefixMode} from '@/modules/parseTaskText'
|
||||||
|
@ -230,13 +230,13 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
playSoundWhenDone(play) {
|
playSoundWhenDone(play) {
|
||||||
if (play) {
|
if (play) {
|
||||||
playPop()
|
playPopSound()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async updateSettings() {
|
async updateSettings() {
|
||||||
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
|
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone ? 'true' : 'false')
|
||||||
setQuickAddMagicMode(this.quickAddMagicMode)
|
setQuickAddMagicMode(this.quickAddMagicMode)
|
||||||
|
|
||||||
await this.$store.dispatch('auth/saveUserSettings', {
|
await this.$store.dispatch('auth/saveUserSettings', {
|
||||||
|
|
Loading…
Reference in a new issue