TimelineQueueButtonHeader: use shortNumberFormat

dnd
Alex Gleason 2022-06-02 20:59:34 -05:00
rodzic 973d3064b5
commit 606d6297a8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ describe('<TimelineQueueButtonHeader />', () => {
undefined, undefined,
{ timelines: fromJS({ home: { totalQueuedItemsCount: 1 } }) }, { timelines: fromJS({ home: { totalQueuedItemsCount: 1 } }) },
); );
expect(screen.getByText('Click to see 1 new post', { hidden: true })).toBeInTheDocument(); expect(screen.getByText(/Click to see\s+1\s+new post/, { hidden: true })).toBeInTheDocument();
render( render(
<TimelineQueueButtonHeader <TimelineQueueButtonHeader
@ -45,6 +45,6 @@ describe('<TimelineQueueButtonHeader />', () => {
undefined, undefined,
{ timelines: fromJS({ home: { totalQueuedItemsCount: 9999999 } }) }, { timelines: fromJS({ home: { totalQueuedItemsCount: 9999999 } }) },
); );
expect(screen.getByText('Click to see 9999999 new posts', { hidden: true })).toBeInTheDocument(); expect(screen.getByText(/10.*M/, { hidden: true })).toBeInTheDocument();
}); });
}); });

Wyświetl plik

@ -6,6 +6,7 @@ import { useIntl, MessageDescriptor } from 'react-intl';
import Icon from 'soapbox/components/icon'; import Icon from 'soapbox/components/icon';
import { Text } from 'soapbox/components/ui'; import { Text } from 'soapbox/components/ui';
import { useAppSelector, useSettings } from 'soapbox/hooks'; import { useAppSelector, useSettings } from 'soapbox/hooks';
import { shortNumberFormat } from 'soapbox/utils/numbers';
interface ITimelineQueueButtonHeader { interface ITimelineQueueButtonHeader {
onClick: () => void, onClick: () => void,
@ -73,7 +74,7 @@ const TimelineQueueButtonHeader: React.FC<ITimelineQueueButtonHeader> = ({
{(count > 0) && ( {(count > 0) && (
<Text theme='inherit' size='sm'> <Text theme='inherit' size='sm'>
{intl.formatMessage(message, { count })} {intl.formatMessage(message, { count: shortNumberFormat(count) })}
</Text> </Text>
)} )}
</a> </a>