Format count and fix type warning (#600)

zio/stable
Ollie H 2023-05-08 14:02:19 -07:00 committed by GitHub
parent 6124e52836
commit 84046f42d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 18 deletions

View File

@ -34,6 +34,7 @@ import {
getProfileModeration, getProfileModeration,
} from 'lib/labeling/helpers' } from 'lib/labeling/helpers'
import {ProfileModeration} from 'lib/labeling/types' import {ProfileModeration} from 'lib/labeling/types'
import {formatCount} from '../util/numeric/format'
const MAX_AUTHORS = 5 const MAX_AUTHORS = 5
@ -218,7 +219,8 @@ export const FeedItem = observer(function ({
<> <>
<Text style={[pal.text]}> and </Text> <Text style={[pal.text]}> and </Text>
<Text style={[pal.text, s.bold]}> <Text style={[pal.text, s.bold]}>
{authors.length - 1} {pluralize(authors.length - 1, 'other')} {formatCount(authors.length - 1)}{' '}
{pluralize(authors.length - 1, 'other')}
</Text> </Text>
</> </>
) : undefined} ) : undefined}

View File

@ -26,6 +26,7 @@ import {PostHider} from '../util/moderation/PostHider'
import {ContentHider} from '../util/moderation/ContentHider' import {ContentHider} from '../util/moderation/ContentHider'
import {ErrorMessage} from '../util/error/ErrorMessage' import {ErrorMessage} from '../util/error/ErrorMessage'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {formatCount} from '../util/numeric/format'
const PARENT_REPLY_LINE_LENGTH = 8 const PARENT_REPLY_LINE_LENGTH = 8
@ -247,7 +248,7 @@ export const PostThreadItem = observer(function PostThreadItem({
title={repostsTitle}> title={repostsTitle}>
<Text testID="repostCount" type="lg" style={pal.textLight}> <Text testID="repostCount" type="lg" style={pal.textLight}>
<Text type="xl-bold" style={pal.text}> <Text type="xl-bold" style={pal.text}>
{item.post.repostCount} {formatCount(item.post.repostCount)}
</Text>{' '} </Text>{' '}
{pluralize(item.post.repostCount, 'repost')} {pluralize(item.post.repostCount, 'repost')}
</Text> </Text>
@ -262,7 +263,7 @@ export const PostThreadItem = observer(function PostThreadItem({
title={likesTitle}> title={likesTitle}>
<Text testID="likeCount" type="lg" style={pal.textLight}> <Text testID="likeCount" type="lg" style={pal.textLight}>
<Text type="xl-bold" style={pal.text}> <Text type="xl-bold" style={pal.text}>
{item.post.likeCount} {formatCount(item.post.likeCount)}
</Text>{' '} </Text>{' '}
{pluralize(item.post.likeCount, 'like')} {pluralize(item.post.likeCount, 'like')}
</Text> </Text>

View File

@ -401,7 +401,7 @@ const ProfileHeaderLoaded = observer(
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
<Text type="md" style={[s.bold, pal.text]}> <Text type="md" style={[s.bold, pal.text]}>
{view.postsCount}{' '} {formatCount(view.postsCount)}{' '}
<Text type="md" style={[pal.textLight]}> <Text type="md" style={[pal.textLight]}>
{pluralize(view.postsCount, 'post')} {pluralize(view.postsCount, 'post')}
</Text> </Text>

View File

@ -36,6 +36,7 @@ import {useAnalytics} from 'lib/analytics'
import {NavigationProp} from 'lib/routes/types' import {NavigationProp} from 'lib/routes/types'
import {isDesktopWeb} from 'platform/detection' import {isDesktopWeb} from 'platform/detection'
import {pluralize} from 'lib/strings/helpers' import {pluralize} from 'lib/strings/helpers'
import {formatCount} from 'view/com/util/numeric/format'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Settings'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'Settings'>
export const SettingsScreen = withAuthRequired( export const SettingsScreen = withAuthRequired(
@ -153,18 +154,22 @@ export const SettingsScreen = withAuthRequired(
contentContainerStyle={!isDesktopWeb && pal.viewLight} contentContainerStyle={!isDesktopWeb && pal.viewLight}
scrollIndicatorInsets={{right: 1}}> scrollIndicatorInsets={{right: 1}}>
<View style={styles.spacer20} /> <View style={styles.spacer20} />
<Text type="xl-bold" style={[pal.text, styles.heading]}> {store.session.currentSession !== undefined ? (
Account <>
</Text> <Text type="xl-bold" style={[pal.text, styles.heading]}>
<View style={[styles.infoLine]}> Account
<Text type="lg-medium" style={pal.text}>
Email:{' '}
<Text type="lg" style={pal.text}>
{store.session.currentSession.email}
</Text> </Text>
</Text> <View style={[styles.infoLine]}>
</View> <Text type="lg-medium" style={pal.text}>
<View style={styles.spacer20} /> Email:{' '}
<Text type="lg" style={pal.text}>
{store.session.currentSession?.email}
</Text>
</Text>
</View>
<View style={styles.spacer20} />
</>
) : null}
<View style={[s.flexRow, styles.heading]}> <View style={[s.flexRow, styles.heading]}>
<Text type="xl-bold" style={pal.text}> <Text type="xl-bold" style={pal.text}>
Signed in as Signed in as
@ -275,7 +280,7 @@ export const SettingsScreen = withAuthRequired(
<Text <Text
type="lg" type="lg"
style={store.me.invitesAvailable > 0 ? pal.link : pal.text}> style={store.me.invitesAvailable > 0 ? pal.link : pal.text}>
{store.me.invitesAvailable} invite{' '} {formatCount(store.me.invitesAvailable)} invite{' '}
{pluralize(store.me.invitesAvailable, 'code')} available {pluralize(store.me.invitesAvailable, 'code')} available
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>

View File

@ -392,7 +392,7 @@ const InviteCodes = observer(() => {
<Text <Text
type="lg-medium" type="lg-medium"
style={store.me.invitesAvailable > 0 ? pal.link : pal.textLight}> style={store.me.invitesAvailable > 0 ? pal.link : pal.textLight}>
{store.me.invitesAvailable} invite{' '} {formatCount(store.me.invitesAvailable)} invite{' '}
{pluralize(store.me.invitesAvailable, 'code')} {pluralize(store.me.invitesAvailable, 'code')}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>

View File

@ -12,6 +12,7 @@ import {useStores} from 'state/index'
import {pluralize} from 'lib/strings/helpers' import {pluralize} from 'lib/strings/helpers'
import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle'
import {MoonIcon} from 'lib/icons' import {MoonIcon} from 'lib/icons'
import {formatCount} from 'view/com/util/numeric/format'
export const DesktopRightNav = observer(function DesktopRightNav() { export const DesktopRightNav = observer(function DesktopRightNav() {
const store = useStores() const store = useStores()
@ -112,7 +113,7 @@ const InviteCodes = observer(() => {
<Text <Text
type="md-medium" type="md-medium"
style={store.me.invitesAvailable > 0 ? pal.link : pal.textLight}> style={store.me.invitesAvailable > 0 ? pal.link : pal.textLight}>
{store.me.invitesAvailable} invite{' '} {formatCount(store.me.invitesAvailable)} invite{' '}
{pluralize(store.me.invitesAvailable, 'code')} available {pluralize(store.me.invitesAvailable, 'code')} available
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>