mirror of
https://github.com/misskey-dev/misskey.git
synced 2025-01-26 03:20:54 +09:00
chore: back to setTimeout
This commit is contained in:
parent
e421ebf508
commit
6b88a6d19d
@ -11,8 +11,6 @@
|
|||||||
import { onUnmounted } from 'vue';
|
import { onUnmounted } from 'vue';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { dateTimeFormat } from '@/scripts/intl-const';
|
import { dateTimeFormat } from '@/scripts/intl-const';
|
||||||
import { defaultIdlingRenderScheduler } from '@/scripts/idle-render.js';
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
time: Date | string | number | null;
|
time: Date | string | number | null;
|
||||||
origin?: Date | null;
|
origin?: Date | null;
|
||||||
@ -46,16 +44,19 @@ const relative = $computed<string>(() => {
|
|||||||
i18n.ts._ago.future);
|
i18n.ts._ago.future);
|
||||||
});
|
});
|
||||||
|
|
||||||
function tick(): void {
|
let tickId: number;
|
||||||
|
|
||||||
|
function tick() {
|
||||||
now = props.origin ?? (new Date()).getTime();
|
now = props.origin ?? (new Date()).getTime();
|
||||||
|
const ago = (now - _time) / 1000/*ms*/;
|
||||||
|
const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000;
|
||||||
|
tickId = window.setTimeout(tick, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.mode === 'relative' || props.mode === 'detail') {
|
if (props.mode === 'relative' || props.mode === 'detail') {
|
||||||
tick();
|
tick();
|
||||||
defaultIdlingRenderScheduler.add(tick);
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
defaultIdlingRenderScheduler.delete(tick);
|
window.clearTimeout(tickId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user