From fd2028df48fa581f713775a01b0925489d21e48c Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Fri, 19 Aug 2022 14:43:52 -0400 Subject: [PATCH] fix: nonblock-statement-body-position lint in time.vue --- .../client/src/components/global/time.vue | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/client/src/components/global/time.vue b/packages/client/src/components/global/time.vue index c4e904350..66eee8674 100644 --- a/packages/client/src/components/global/time.vue +++ b/packages/client/src/components/global/time.vue @@ -36,22 +36,26 @@ let now = $ref(new Date()); const relative = $computed(() => { const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/; - if (ago >= 31536000) + if (ago >= 31536000) { return i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }); - if (ago >= 2592000) + } else if (ago >= 2592000) { return i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }); - if (ago >= 604800) + } else if (ago >= 604800) { return i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }); - if (ago >= 86400) + } else if (ago >= 86400) { return i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }); + } // if the format is 'date', the relative date precision is no more than days ago - if (props.format !== 'date' && ago >= 3600) - return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }); - if (props.format !== 'date' && ago >= 60) - return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }); - if (props.format !== 'date' && ago >= 10) - return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }); + if (props.format !== 'date') { + if (ago >= 3600) { + return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }); + } else if (ago >= 60) { + return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }); + } else if (ago >= 10) { + return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }); + } + } if (ago >= -5) { if (props.format === 'date') {