Skip to content

Commit e1aeb63

Browse files
committed
Fix: add account doesn't work on window focus lose
1 parent 066d579 commit e1aeb63

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

src/App.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
2+
import { whenever } from '@vueuse/core'
23
import { computed, watch, watchEffect } from 'vue'
3-
import { useTauriEvent } from './composables/useTauriEvent'
4+
import { useCountDown } from './composables/useCountDown'
45
import * as Gitification from './gitification/index'
56
import * as UI from './ui'
67
import * as Views from './views'
@@ -39,11 +40,21 @@ watch(() => Gitification.state.theme, (theme) => {
3940
}
4041
}, { immediate: true })
4142
42-
useTauriEvent('window:hidden', () => {
43-
if (Gitification.state.currentUser != null) {
44-
Gitification.router.navigate('home')
45-
}
43+
const [timerZero, resetTimer] = useCountDown(5)
44+
45+
whenever(timerZero, () => {
46+
resetTimer()
47+
48+
Gitification.actions
49+
.fetchThreads()
4650
})
51+
52+
whenever(() => Gitification.state.currentUser, () => {
53+
resetTimer()
54+
55+
Gitification.actions
56+
.fetchThreads()
57+
}, { immediate: true })
4758
</script>
4859

4960
<template>

src/views/HomeView.vue

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ useKey('esc', Gitification.actions.clearThreadSelection)
2929
useTauriEvent('window:hidden', Gitification.actions.clearThreadSelection)
3030
onScopeDispose(Gitification.actions.clearThreadSelection)
3131
32-
const [timerZero, resetTimer] = useCountDown(60)
33-
34-
whenever(timerZero, () => {
35-
Gitification.actions
36-
.fetchThreads()
37-
.finally(resetTimer)
38-
})
39-
40-
onMounted(() => {
41-
Gitification.actions
42-
.fetchThreads(true)
43-
.finally(resetTimer)
44-
})
45-
4632
// Click empty space to clear selection
4733
useEventListener(
4834
() => document.querySelector('#app') as HTMLElement,

0 commit comments

Comments
 (0)