mirror of
https://github.com/sim1222/misskey.git
synced 2025-08-04 07:26:29 +09:00
enhance: RSSウィジェット / RSSティッカーウィジェットをいい感じにする (#9469)
* ✌️ * use useInterval * ✌️ * rawItems.value.length !== 0 * fix * https://github.com/misskey-dev/misskey/pull/9469#discussion_r1061763613
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user