forked from Mirrors/elk
fix: format many voters as human readable number
This commit is contained in:
parent
2fed89be9d
commit
be68912226
2 changed files with 3 additions and 2 deletions
|
@ -13,6 +13,7 @@ function toPercentage(num: number) {
|
||||||
const timeAgoOptions = useTimeAgoOptions()
|
const timeAgoOptions = useTimeAgoOptions()
|
||||||
const expiredTimeAgo = useTimeAgo(poll.expiresAt!, timeAgoOptions)
|
const expiredTimeAgo = useTimeAgo(poll.expiresAt!, timeAgoOptions)
|
||||||
const expiredTimeFormatted = useFormattedDateTime(poll.expiresAt!)
|
const expiredTimeFormatted = useFormattedDateTime(poll.expiresAt!)
|
||||||
|
const { formatHumanReadableNumber } = useHumanReadableNumber()
|
||||||
|
|
||||||
const masto = useMasto()
|
const masto = useMasto()
|
||||||
async function vote(e: Event) {
|
async function vote(e: Event) {
|
||||||
|
@ -57,7 +58,7 @@ async function vote(e: Event) {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div text-sm>
|
<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">
|
<CommonTooltip :content="expiredTimeFormatted" class="inline-block" placement="right">
|
||||||
<time :datetime="poll.expiresAt!">{{ $t(poll.expired ? 'status.poll.finished' : 'status.poll.ends', [expiredTimeAgo]) }}</time>
|
<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()
|
const formatter = Intl.NumberFormat()
|
||||||
|
|
||||||
export const humanReadableNumber = (
|
const humanReadableNumber = (
|
||||||
num: number,
|
num: number,
|
||||||
{ k, m }: { k: string; m: string } = { k: 'K', m: 'M' },
|
{ k, m }: { k: string; m: string } = { k: 'K', m: 'M' },
|
||||||
useFormatter: Intl.NumberFormat = formatter,
|
useFormatter: Intl.NumberFormat = formatter,
|
||||||
|
|
Loading…
Reference in a new issue