fix: format many voters as human readable number
parent
2fed89be9d
commit
be68912226
|
@ -13,6 +13,7 @@ function toPercentage(num: number) {
|
|||
const timeAgoOptions = useTimeAgoOptions()
|
||||
const expiredTimeAgo = useTimeAgo(poll.expiresAt!, timeAgoOptions)
|
||||
const expiredTimeFormatted = useFormattedDateTime(poll.expiresAt!)
|
||||
const { formatHumanReadableNumber } = useHumanReadableNumber()
|
||||
|
||||
const masto = useMasto()
|
||||
async function vote(e: Event) {
|
||||
|
@ -57,7 +58,7 @@ async function vote(e: Event) {
|
|||
</div>
|
||||
</template>
|
||||
<div text-sm>
|
||||
{{ $t('status.poll.count', poll.votersCount ?? 0) }}
|
||||
{{ $t('status.poll.count', formatHumanReadableNumber(poll.votersCount ?? 0)) }}
|
||||
·
|
||||
<CommonTooltip :content="expiredTimeFormatted" class="inline-block" placement="right">
|
||||
<time :datetime="poll.expiresAt!">{{ $t(poll.expired ? 'status.poll.finished' : 'status.poll.ends', [expiredTimeAgo]) }}</time>
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { MaybeComputedRef, UseTimeAgoOptions } from '@vueuse/core'
|
|||
|
||||
const formatter = Intl.NumberFormat()
|
||||
|
||||
export const humanReadableNumber = (
|
||||
const humanReadableNumber = (
|
||||
num: number,
|
||||
{ k, m }: { k: string; m: string } = { k: 'K', m: 'M' },
|
||||
useFormatter: Intl.NumberFormat = formatter,
|
||||
|
|
Loading…
Reference in New Issue