1
0

feat: simplify playPopSound setting check

This commit is contained in:
Dominik Pschenitschni 2024-07-05 14:24:53 +02:00
parent 5cf57a520c
commit 42c458a736
No known key found for this signature in database
GPG Key ID: B257AC0149F43A77
5 changed files with 11 additions and 9 deletions

View File

@ -111,7 +111,6 @@ import {formatDateLong, formatISO, formatDateSince} from '@/helpers/time/formatD
import {colorIsDark} from '@/helpers/color/colorIsDark'
import {useTaskStore} from '@/stores/tasks'
import AssigneeList from '@/components/tasks/partials/AssigneeList.vue'
import {useAuthStore} from '@/stores/auth'
import {playPopSound} from '@/helpers/playPop'
import {isEditorContentEmpty} from '@/helpers/editorContentEmpty'
@ -137,7 +136,7 @@ async function toggleTaskDone(task: ITask) {
done: !task.done,
})
if (updatedTask.done && useAuthStore().settings.frontendSettings.playSoundWhenDone) {
if (updatedTask.done) {
playPopSound()
}
} finally {

View File

@ -204,7 +204,6 @@ import FancyCheckbox from '@/components/input/FancyCheckbox.vue'
import {error, success} from '@/message'
import {useTaskStore} from '@/stores/tasks'
import {useProjectStore} from '@/stores/projects'
import {useAuthStore} from '@/stores/auth'
import {playPopSound} from '@/helpers/playPop'
const props = defineProps({
@ -380,7 +379,7 @@ async function createAndRelateTask(title: string) {
async function toggleTaskDone(task: ITask) {
await taskStore.update(task)
if (task.done && useAuthStore().settings.frontendSettings.playSoundWhenDone) {
if (task.done) {
playPopSound()
}

View File

@ -205,7 +205,6 @@ import {useTaskStore} from '@/stores/tasks'
import AssigneeList from '@/components/tasks/partials/AssigneeList.vue'
import {useIntervalFn} from '@vueuse/core'
import {playPopSound} from '@/helpers/playPop'
import {useAuthStore} from '@/stores/auth'
import {isEditorContentEmpty} from '@/helpers/editorContentEmpty'
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
@ -311,7 +310,7 @@ async function markAsDone(checked: boolean, wasReverted: boolean = false) {
return
}
if (checked && useAuthStore().settings.frontendSettings.playSoundWhenDone) {
if (checked) {
playPopSound()
}
emit('taskUpdated', newTask)

View File

@ -1,8 +1,13 @@
import {useAuthStore} from '@/stores/auth'
import popSoundFile from '@/assets/audio/pop.mp3'
export const playSoundWhenDoneKey = 'playSoundWhenTaskDone'
export function playPopSound() {
const playSoundWhenDone = useAuthStore().settings.frontendSettings.playSoundWhenDone
if (!playSoundWhenDone)
return
try {
const popSound = new Audio(popSoundFile)
popSound.play()

View File

@ -879,7 +879,7 @@ function toggleTaskDone() {
done: !task.value.done,
}
if (newTask.done && authStore.settings.frontendSettings.playSoundWhenDone) {
if (newTask.done) {
playPopSound()
}