diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-26 03:12:58 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-26 03:12:58 +0900 |
| commit | 5e95a1f7af841f10646133ad0cc155a2c5cea9fd (patch) | |
| tree | 6aacbbdca450e7a0ae54e7040147395c934e787b /packages/client/src/components/global | |
| parent | enhance(client): tweak control panel dashboard (diff) | |
| download | misskey-5e95a1f7af841f10646133ad0cc155a2c5cea9fd.tar.gz misskey-5e95a1f7af841f10646133ad0cc155a2c5cea9fd.tar.bz2 misskey-5e95a1f7af841f10646133ad0cc155a2c5cea9fd.zip | |
refactor(client): extract interval logic to a composable function
あと`onUnmounted`を`onMounted`内で呼んでいたりしたのを修正したりとか
Diffstat (limited to 'packages/client/src/components/global')
| -rw-r--r-- | packages/client/src/components/global/time.vue | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/client/src/components/global/time.vue b/packages/client/src/components/global/time.vue index a7f142f961..801490225b 100644 --- a/packages/client/src/components/global/time.vue +++ b/packages/client/src/components/global/time.vue @@ -24,14 +24,14 @@ let now = $ref(new Date()); const relative = $computed(() => { const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/; return ( - ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) : - ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) : - ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) : - ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) : - ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) : - ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : - ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : - ago >= -1 ? i18n.ts._ago.justNow : + ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) : + ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) : + ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) : + ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) : + ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) : + ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : + ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : + ago >= -1 ? i18n.ts._ago.justNow : i18n.ts._ago.future); }); @@ -50,7 +50,7 @@ if (props.mode === 'relative' || props.mode === 'detail') { tickId = window.requestAnimationFrame(tick); onUnmounted(() => { - window.clearTimeout(tickId); + window.cancelAnimationFrame(tickId); }); } </script> |