Skip to content

Commit

Permalink
Followers/following exact count (#7057)
Browse files Browse the repository at this point in the history
* followers exact count in heading

* exact count for following

* move files to new dir

* use <Plural>
  • Loading branch information
mozzius authored Dec 11, 2024
1 parent 7db5882 commit 89c6ca9
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 70 deletions.
4 changes: 2 additions & 2 deletions src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ import {PrivacyPolicyScreen} from '#/view/screens/PrivacyPolicy'
import {ProfileScreen} from '#/view/screens/Profile'
import {ProfileFeedScreen} from '#/view/screens/ProfileFeed'
import {ProfileFeedLikedByScreen} from '#/view/screens/ProfileFeedLikedBy'
import {ProfileFollowersScreen} from '#/view/screens/ProfileFollowers'
import {ProfileFollowsScreen} from '#/view/screens/ProfileFollows'
import {ProfileListScreen} from '#/view/screens/ProfileList'
import {SavedFeeds} from '#/view/screens/SavedFeeds'
import {SearchScreen} from '#/view/screens/Search'
Expand All @@ -77,6 +75,8 @@ import {PostLikedByScreen} from '#/screens/Post/PostLikedBy'
import {PostQuotesScreen} from '#/screens/Post/PostQuotes'
import {PostRepostedByScreen} from '#/screens/Post/PostRepostedBy'
import {ProfileKnownFollowersScreen} from '#/screens/Profile/KnownFollowers'
import {ProfileFollowersScreen} from '#/screens/Profile/ProfileFollowers'
import {ProfileFollowsScreen} from '#/screens/Profile/ProfileFollows'
import {ProfileLabelerLikedByScreen} from '#/screens/Profile/ProfileLabelerLikedBy'
import {AppearanceSettingsScreen} from '#/screens/Settings/AppearanceSettings'
import {AppIconSettingsScreen} from '#/screens/Settings/AppIconSettings'
Expand Down
56 changes: 56 additions & 0 deletions src/screens/Profile/ProfileFollowers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react'
import {Plural} from '@lingui/macro'
import {useFocusEffect} from '@react-navigation/native'

import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {useProfileQuery} from '#/state/queries/profile'
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileFollowers as ProfileFollowersComponent} from '#/view/com/profile/ProfileFollowers'
import * as Layout from '#/components/Layout'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollowers'>
export const ProfileFollowersScreen = ({route}: Props) => {
const {name} = route.params
const setMinimalShellMode = useSetMinimalShellMode()

const {data: resolvedDid} = useResolveDidQuery(name)
const {data: profile} = useProfileQuery({
did: resolvedDid,
})

useFocusEffect(
React.useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)

return (
<Layout.Screen testID="profileFollowersScreen">
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
{profile && (
<>
<Layout.Header.TitleText>
{sanitizeDisplayName(profile.displayName || profile.handle)}
</Layout.Header.TitleText>
<Layout.Header.SubtitleText>
<Plural
value={profile.followersCount ?? 0}
one="# follower"
other="# followers"
/>
</Layout.Header.SubtitleText>
</>
)}
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<Layout.Center>
<ProfileFollowersComponent name={name} />
</Layout.Center>
</Layout.Screen>
)
}
56 changes: 56 additions & 0 deletions src/screens/Profile/ProfileFollows.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react'
import {Plural} from '@lingui/macro'
import {useFocusEffect} from '@react-navigation/native'

import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {useProfileQuery} from '#/state/queries/profile'
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileFollows as ProfileFollowsComponent} from '#/view/com/profile/ProfileFollows'
import * as Layout from '#/components/Layout'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollows'>
export const ProfileFollowsScreen = ({route}: Props) => {
const {name} = route.params
const setMinimalShellMode = useSetMinimalShellMode()

const {data: resolvedDid} = useResolveDidQuery(name)
const {data: profile} = useProfileQuery({
did: resolvedDid,
})

useFocusEffect(
React.useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)

return (
<Layout.Screen testID="profileFollowsScreen">
<Layout.Header.Outer>
<Layout.Header.BackButton />
<Layout.Header.Content>
{profile && (
<>
<Layout.Header.TitleText>
{sanitizeDisplayName(profile.displayName || profile.handle)}
</Layout.Header.TitleText>
<Layout.Header.SubtitleText>
<Plural
value={profile.followersCount ?? 0}
one="# following"
other="# following"
/>
</Layout.Header.SubtitleText>
</>
)}
</Layout.Header.Content>
<Layout.Header.Slot />
</Layout.Header.Outer>
<Layout.Center>
<ProfileFollowsComponent name={name} />
</Layout.Center>
</Layout.Screen>
)
}
34 changes: 0 additions & 34 deletions src/view/screens/ProfileFollowers.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions src/view/screens/ProfileFollows.tsx

This file was deleted.

0 comments on commit 89c6ca9

Please sign in to comment.