Skip to content

Commit b02e141

Browse files
committed
fix(polling): disable polling when document is not visible
1 parent b57358f commit b02e141

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"clear": "rimraf dist",
3333
"dist": "pnpm run clear && esno scripts/prepare.ts",
3434
"type:check": "vue-tsc --build",
35-
"vite:serve": "vite --host",
35+
"vite:serve": "vite",
3636
"vite:build": "vite build",
37-
"vite:preview": "vite preview --host",
37+
"vite:preview": "vite preview",
3838
"dev": "cross-env NODE_ENV=development run-p dist vite:serve",
3939
"dev:web": "VITE_SOURCEMAP=true VITE_WEB=true VITE_BASE=/trakt-extension/ run-s dev",
4040
"build": "cross-env NODE_ENV=production run-s dist type:check 'vite:build {@}' --",

src/stores/data/activity.store.ts

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export const useActivityStore = defineStore(ActivityStoreConstants.Store, () =>
191191
async () => {
192192
if (interval.value) clearInterval(interval.value);
193193
if (!polling.value) return;
194+
if (document.hidden) return;
194195
if (isAuthenticated.value) await fetchActivity();
195196
interval.value = setInterval(() => {
196197
if (!isAuthenticated.value) return;

src/stores/data/watching.store.ts

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const useWatchingStore = defineStore(WatchingStoreConstants.Store, () =>
153153
async () => {
154154
if (interval.value) clearInterval(interval.value);
155155
if (!polling.value) return;
156+
if (document.hidden) return;
156157
if (isAuthenticated.value) await fetchWatching();
157158
interval.value = setInterval(() => {
158159
if (!isAuthenticated.value) return;

0 commit comments

Comments
 (0)