Skip to content

Commit

Permalink
fix: timer null
Browse files Browse the repository at this point in the history
  • Loading branch information
hanaTsuk1 committed Jul 21, 2024
1 parent 417802f commit 8ab53a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/stores/useTimerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const useTimerStore = defineStore('timer', () => {
let startTime = 0
const FPS = 60

let taskTimer: Timer
let countTimer: Timer
let taskTimer: Timer | null = null
let countTimer: Timer | null = null

function start(update: () => Promise<unknown>) {
running.value = true
Expand All @@ -24,8 +24,8 @@ export const useTimerStore = defineStore('timer', () => {

async function finish() {
running.value = false
await taskTimer.destroy(true)
countTimer.destroy()
await taskTimer?.destroy(true)
countTimer?.destroy()
reset()
}

Expand All @@ -51,11 +51,11 @@ export const useTimerStore = defineStore('timer', () => {
})

onAppSuspend(() => {
taskTimer.destroy()
taskTimer?.destroy()
})

onAppResume(() => {
taskTimer.restart()
taskTimer?.restart()
})

return {
Expand Down

0 comments on commit 8ab53a7

Please sign in to comment.