diff options
Diffstat (limited to 'src/components/profile/Content.tsx')
-rw-r--r-- | src/components/profile/Content.tsx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 50e9d627..8d69b3b0 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -11,7 +11,11 @@ import {Moment} from '../moments'; import ProfileBody from './ProfileBody'; import ProfileCutout from './ProfileCutout'; import ProfileHeader from './ProfileHeader'; -import {loadFollowers, followOrUnfollowUser} from '../../services'; +import { + loadFollowers, + loadFollowing, + followOrUnfollowUser, +} from '../../services'; interface ContentProps { y: Animated.Value<number>; @@ -33,6 +37,9 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => { const [followers, setFollowers] = React.useState<Array<ProfilePreviewType>>( [], ); + const [following, setFollowing] = React.useState<Array<ProfilePreviewType>>( + [], + ); const {user: loggedInUser} = React.useContext(AuthContext); /** @@ -110,6 +117,11 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => { token, ); + const listFollowing: ProfilePreviewType[] = await loadFollowing( + userId, + token, + ); + /** * Check if the logged in user actually follows the user being viewed. */ @@ -121,14 +133,10 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => { setFollowed(isActuallyFollowed); } setFollowers(listFollowers); + setFollowing(listFollowing); }; - /** - * Update the followed value if and only if a profile is being viewed and you are loading a profile afresh that is not your own profile. - */ - if (isProfileView && !isOwnProfile) { - updateFollowedValue(); - } + updateFollowedValue(); }, []); /** @@ -158,8 +166,12 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => { showsVerticalScrollIndicator={false} scrollEventThrottle={1} stickyHeaderIndices={[2, 4]}> - <ProfileCutout/> - <ProfileHeader {...{isProfileView}} /> + <ProfileCutout /> + <ProfileHeader + isProfileView={isProfileView} + numFollowing={following.length} + numFollowers={followers.length} + /> <ProfileBody {...{ onLayout, |