fix: format many voters as human readable number

pull/377/head
Daniel Roe 2022-12-08 11:56:23 +01:00
rodzic 2fed89be9d
commit be68912226
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 22D5008E4F5D9B55
2 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -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)) }}
&middot;
<CommonTooltip :content="expiredTimeFormatted" class="inline-block" placement="right">
<time :datetime="poll.expiresAt!">{{ $t(poll.expired ? 'status.poll.finished' : 'status.poll.ends', [expiredTimeAgo]) }}</time>

Wyświetl plik

@ -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,