diff --git a/src/apps/dashboard/features/metrics/components/MetricCard.tsx b/src/apps/dashboard/features/metrics/components/MetricCard.tsx index 102d9da730..5ab87bc167 100644 --- a/src/apps/dashboard/features/metrics/components/MetricCard.tsx +++ b/src/apps/dashboard/features/metrics/components/MetricCard.tsx @@ -7,7 +7,7 @@ import Typography from '@mui/material/Typography'; import React, { type FC } from 'react'; import { useLocale } from 'hooks/useLocale'; -import { toLocaleString } from 'utils/number'; +import { toDecimalString } from 'utils/number'; interface Metric { label: string @@ -54,8 +54,8 @@ const MetricCard: FC = ({ variant='h5' component='div' > - {value ? ( - toLocaleString(value, dateTimeLocale) + {typeof value !== 'undefined' ? ( + toDecimalString(value, dateTimeLocale) ) : ( )} diff --git a/src/elements/emby-itemrefreshindicator/RefreshIndicator.tsx b/src/elements/emby-itemrefreshindicator/RefreshIndicator.tsx index 79f6a8cf35..edd834a9e0 100644 --- a/src/elements/emby-itemrefreshindicator/RefreshIndicator.tsx +++ b/src/elements/emby-itemrefreshindicator/RefreshIndicator.tsx @@ -9,7 +9,7 @@ import CircularProgress, { } from '@mui/material/CircularProgress'; import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; -import { toPercent } from 'utils/number'; +import { toPercentString } from 'utils/number'; import { getCurrentDateTimeLocale } from 'lib/globalize'; import type { ItemDto } from 'types/base/models/item-dto'; @@ -36,7 +36,7 @@ function CircularProgressWithLabel( component='div' color='text.secondary' > - {toPercent(props.value / 100, getCurrentDateTimeLocale())} + {toPercentString(props.value / 100, getCurrentDateTimeLocale())} diff --git a/src/elements/emby-progressring/emby-progressring.js b/src/elements/emby-progressring/emby-progressring.js index fee77e5ec7..ce4b061bd9 100644 --- a/src/elements/emby-progressring/emby-progressring.js +++ b/src/elements/emby-progressring/emby-progressring.js @@ -2,7 +2,7 @@ import './emby-progressring.scss'; import 'webcomponents.js/webcomponents-lite'; import template from './emby-progressring.template.html'; import { getCurrentDateTimeLocale } from '../../lib/globalize'; -import { toPercent } from '../../utils/number.ts'; +import { toPercentString } from '../../utils/number.ts'; const EmbyProgressRing = Object.create(HTMLDivElement.prototype); @@ -71,7 +71,7 @@ EmbyProgressRing.setProgress = function (progress) { this.querySelector('.animate-75-100-b').style.transform = 'rotate(' + angle + 'deg)'; } - this.querySelector('.progressring-text').innerHTML = toPercent(progress / 100, getCurrentDateTimeLocale()); + this.querySelector('.progressring-text').innerHTML = toPercentString(progress / 100, getCurrentDateTimeLocale()); }; EmbyProgressRing.attachedCallback = function () { diff --git a/src/utils/number.ts b/src/utils/number.ts index d411addcda..b68879523c 100644 --- a/src/utils/number.ts +++ b/src/utils/number.ts @@ -19,7 +19,7 @@ export function randomInt(min: number, max: number): number { * @param {string} locale The locale to use for formatting (i.e. en-us). * @returns {string} The value formatted as a string. */ -export function toLocaleString(value: number, locale: string): string { +export function toDecimalString(value: number, locale: string): string { if (toLocaleStringSupportsOptions()) { return value.toLocaleString(locale); } @@ -33,7 +33,7 @@ export function toLocaleString(value: number, locale: string): string { * @param {string} locale The locale to use for formatting (i.e. en-us). * @returns {string} The value formatted as a percentage. */ -export function toPercent(value: number | null | undefined, locale: string): string { +export function toPercentString(value: number | null | undefined, locale: string): string { if (value == null) { return ''; }