diff options
author | Husam Salhab <47015061+hsalhab@users.noreply.github.com> | 2020-10-26 18:42:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-26 18:42:02 -0400 |
commit | 17fbfa29c1b78703b872221e3b590aca3ef5cf7e (patch) | |
tree | ed3ede72471f117f7bb81da47b9e6276eaa01f55 /src/components/profile/Content.tsx | |
parent | 61bcb48511095d5568a013429b0092c57659df0e (diff) |
[TMA-13] List of following (#72)
* move async-storage
* removed lock files
* added lock files to gitignore
* added the wrong file to gitignore
* added following list
* added numFollowers; removed redundant code
* removed followercount stuff for now
* Fixed follower count
* Made come more changes
Co-authored-by: Ashm Walia <ashmwalia@outlook.com>
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, |