From 84046f42d575d57109bf4806740569c689cab98f Mon Sep 17 00:00:00 2001 From: Ollie H Date: Mon, 8 May 2023 14:02:19 -0700 Subject: [PATCH] Format count and fix type warning (#600) --- src/view/com/notifications/FeedItem.tsx | 4 ++- src/view/com/post-thread/PostThreadItem.tsx | 5 ++-- src/view/com/profile/ProfileHeader.tsx | 2 +- src/view/screens/Settings.tsx | 29 ++++++++++++--------- src/view/shell/Drawer.tsx | 2 +- src/view/shell/desktop/RightNav.tsx | 3 ++- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index 4ca5fb01a1..ac2e2a1904 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -34,6 +34,7 @@ import { getProfileModeration, } from 'lib/labeling/helpers' import {ProfileModeration} from 'lib/labeling/types' +import {formatCount} from '../util/numeric/format' const MAX_AUTHORS = 5 @@ -218,7 +219,8 @@ export const FeedItem = observer(function ({ <> and - {authors.length - 1} {pluralize(authors.length - 1, 'other')} + {formatCount(authors.length - 1)}{' '} + {pluralize(authors.length - 1, 'other')} ) : undefined} diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index ddb2cb7bbd..d657c92c38 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -26,6 +26,7 @@ import {PostHider} from '../util/moderation/PostHider' import {ContentHider} from '../util/moderation/ContentHider' import {ErrorMessage} from '../util/error/ErrorMessage' import {usePalette} from 'lib/hooks/usePalette' +import {formatCount} from '../util/numeric/format' const PARENT_REPLY_LINE_LENGTH = 8 @@ -247,7 +248,7 @@ export const PostThreadItem = observer(function PostThreadItem({ title={repostsTitle}> - {item.post.repostCount} + {formatCount(item.post.repostCount)} {' '} {pluralize(item.post.repostCount, 'repost')} @@ -262,7 +263,7 @@ export const PostThreadItem = observer(function PostThreadItem({ title={likesTitle}> - {item.post.likeCount} + {formatCount(item.post.likeCount)} {' '} {pluralize(item.post.likeCount, 'like')} diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index d3945ea2a4..d69cf4a122 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -401,7 +401,7 @@ const ProfileHeaderLoaded = observer( - {view.postsCount}{' '} + {formatCount(view.postsCount)}{' '} {pluralize(view.postsCount, 'post')} diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index 6ec263c563..5559f036dc 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -36,6 +36,7 @@ import {useAnalytics} from 'lib/analytics' import {NavigationProp} from 'lib/routes/types' import {isDesktopWeb} from 'platform/detection' import {pluralize} from 'lib/strings/helpers' +import {formatCount} from 'view/com/util/numeric/format' type Props = NativeStackScreenProps export const SettingsScreen = withAuthRequired( @@ -153,18 +154,22 @@ export const SettingsScreen = withAuthRequired( contentContainerStyle={!isDesktopWeb && pal.viewLight} scrollIndicatorInsets={{right: 1}}> - - Account - - - - Email:{' '} - - {store.session.currentSession.email} + {store.session.currentSession !== undefined ? ( + <> + + Account - - - + + + Email:{' '} + + {store.session.currentSession?.email} + + + + + + ) : null} Signed in as @@ -275,7 +280,7 @@ export const SettingsScreen = withAuthRequired( 0 ? pal.link : pal.text}> - {store.me.invitesAvailable} invite{' '} + {formatCount(store.me.invitesAvailable)} invite{' '} {pluralize(store.me.invitesAvailable, 'code')} available diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index 1b8983e83a..bdd64807eb 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -392,7 +392,7 @@ const InviteCodes = observer(() => { 0 ? pal.link : pal.textLight}> - {store.me.invitesAvailable} invite{' '} + {formatCount(store.me.invitesAvailable)} invite{' '} {pluralize(store.me.invitesAvailable, 'code')} diff --git a/src/view/shell/desktop/RightNav.tsx b/src/view/shell/desktop/RightNav.tsx index 142f011638..d6663ce3d6 100644 --- a/src/view/shell/desktop/RightNav.tsx +++ b/src/view/shell/desktop/RightNav.tsx @@ -12,6 +12,7 @@ import {useStores} from 'state/index' import {pluralize} from 'lib/strings/helpers' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {MoonIcon} from 'lib/icons' +import {formatCount} from 'view/com/util/numeric/format' export const DesktopRightNav = observer(function DesktopRightNav() { const store = useStores() @@ -112,7 +113,7 @@ const InviteCodes = observer(() => { 0 ? pal.link : pal.textLight}> - {store.me.invitesAvailable} invite{' '} + {formatCount(store.me.invitesAvailable)} invite{' '} {pluralize(store.me.invitesAvailable, 'code')} available