Skip to content

Commit 5bf49ee

Browse files
committed
Keep fetch interval alive in all pages
1 parent 1390438 commit 5bf49ee

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/App.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import AppContent from './components/AppContent.vue'
33
import AppSidebar from './components/AppSidebar.vue'
44
import HomePage from './pages/HomePage.vue'
55
import SettingsPage from './pages/SettingsPage.vue'
6-
import { Page } from './constants'
6+
import { FETCH_INTERVAL_DURATION, Page } from './constants'
77
import { useStore } from './stores/store'
88
import LandingPage from './pages/LandingPage.vue'
9+
import { useInterval } from './composables/useInterval'
10+
import { AppStorage } from './storage'
911
1012
const store = useStore()
13+
14+
useInterval(() => {
15+
if (AppStorage.get('accessToken') && AppStorage.get('user'))
16+
store.fetchNotifications()
17+
}, FETCH_INTERVAL_DURATION)
1118
</script>
1219

1320
<template>

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Icons } from './components/Icons'
22

33
export const SERVER_PORT = 23846
44
export const REPO_LINK = 'https://github.com/Gitification-App/gitification'
5+
export const FETCH_INTERVAL_DURATION = 60000
56

67
export enum Page {
78
Settings = 'Settings',

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ app.use(pinia)
2424
const store = useStore(pinia)
2525
const token = AppStorage.get('accessToken')
2626
const user = AppStorage.get('user')
27+
2728
AppStorage.set('openAtStartup', await isAutostartEnabled())
2829

2930
if (token && user)

src/pages/HomePage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import AppButton from '../components/AppButton.vue'
2020
2121
const store = useStore()
2222
23-
store.fetchNotifications(store.pageFrom === Page.Landing || store.notifications.length === 0)
24-
useInterval(store.fetchNotifications, 60000)
23+
if (store.pageFrom === Page.Landing || store.pageFrom == null)
24+
store.fetchNotifications(true)
2525
2626
function handleNotificationClick(notification: Thread) {
2727
const url = toGithubWebURL({ notification, userId: AppStorage.get('user')!.id })

0 commit comments

Comments
 (0)