mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-22 16:24:17 +02:00
refactor(client): extract interval logic to a composable function
あと`onUnmounted`を`onMounted`内で呼んでいたりしたのを修正したりとか
This commit is contained in:
@@ -19,11 +19,12 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUnmounted, ref } from 'vue';
|
||||
import { GetFormResultType } from '@/scripts/form';
|
||||
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
|
||||
import { GetFormResultType } from '@/scripts/form';
|
||||
import MkContainer from '@/components/ui/container.vue';
|
||||
import MkMiniChart from '@/components/mini-chart.vue';
|
||||
import * as os from '@/os';
|
||||
import { useInterval } from '@/scripts/use-interval';
|
||||
|
||||
const name = 'hashtags';
|
||||
|
||||
@@ -58,12 +59,9 @@ const fetch = () => {
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetch();
|
||||
const intervalId = window.setInterval(fetch, 1000 * 60);
|
||||
onUnmounted(() => {
|
||||
window.clearInterval(intervalId);
|
||||
});
|
||||
useInterval(fetch, 1000 * 60, {
|
||||
immediate: true,
|
||||
afterMounted: true,
|
||||
});
|
||||
|
||||
defineExpose<WidgetComponentExpose>({
|
||||
|
||||
Reference in New Issue
Block a user