diff --git a/packages/frontend/src/scripts/use-interval.ts b/packages/frontend/src/scripts/use-interval.ts index 201ba417ef..601dea6724 100644 --- a/packages/frontend/src/scripts/use-interval.ts +++ b/packages/frontend/src/scripts/use-interval.ts @@ -3,7 +3,7 @@ import { onMounted, onUnmounted } from 'vue'; export function useInterval(fn: () => void, interval: number, options: { immediate: boolean; afterMounted: boolean; -}): void { +}): (() => void) | undefined { if (Number.isNaN(interval)) return; let intervalId: number | null = null; @@ -18,7 +18,14 @@ export function useInterval(fn: () => void, interval: number, options: { intervalId = window.setInterval(fn, interval); } - onUnmounted(() => { + const clear = () => { if (intervalId) window.clearInterval(intervalId); + intervalId = null; + }; + + onUnmounted(() => { + clear(); }); + + return clear; } diff --git a/packages/frontend/src/widgets/rss-ticker.vue b/packages/frontend/src/widgets/rss-ticker.vue index c2d6dd2873..37672e13cf 100644 --- a/packages/frontend/src/widgets/rss-ticker.vue +++ b/packages/frontend/src/widgets/rss-ticker.vue @@ -3,13 +3,15 @@ RSS -