diff options
Diffstat (limited to 'src/components/profile/ProfileBody.tsx')
-rw-r--r-- | src/components/profile/ProfileBody.tsx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx index c0253533..3c05fc26 100644 --- a/src/components/profile/ProfileBody.tsx +++ b/src/components/profile/ProfileBody.tsx @@ -1,33 +1,38 @@ -import React from 'react'; +import React, {useContext} from 'react'; import {StyleSheet, View, Text, LayoutChangeEvent} from 'react-native'; import {TAGG_DARK_BLUE, TOGGLE_BUTTON_TYPE} from '../../constants'; -import {AuthContext, ProfileContext} from '../../routes/'; import ToggleButton from './ToggleButton'; +import {RootState} from '../../store/rootReducer'; +import {useSelector} from 'react-redux'; +import {ScreenType} from '../../types'; +import {NO_PROFILE} from '../../store/initialStates'; interface ProfileBodyProps { onLayout: (event: LayoutChangeEvent) => void; - isProfileView: boolean; isFollowed: boolean; isBlocked: boolean; isOwnProfile: boolean; handleFollowUnfollow: Function; handleBlockUnblock: Function; + userXId: string; + screenType: ScreenType; } const ProfileBody: React.FC<ProfileBodyProps> = ({ onLayout, - isProfileView, isFollowed, isBlocked, isOwnProfile, handleFollowUnfollow, handleBlockUnblock, + userXId, + screenType, }) => { const { - profile, + profile = NO_PROFILE, user: {username}, - } = isProfileView - ? React.useContext(ProfileContext) - : React.useContext(AuthContext); + } = userXId + ? useSelector((state: RootState) => state.userX[screenType][userXId]) + : useSelector((state: RootState) => state.user); const {biography, website} = profile; @@ -36,7 +41,7 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ <Text style={styles.username}>{`@${username}`}</Text> <Text style={styles.biography}>{`${biography}`}</Text> <Text style={styles.website}>{`${website}`}</Text> - {isProfileView && !isOwnProfile ? ( + {userXId && !isOwnProfile ? ( <View style={styles.toggleButtonContainer}> {!isBlocked && ( <ToggleButton |