diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:00:39 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:00:39 -0400 |
| commit | e8324a7278a82d926acceedc10921f0b14e6d403 (patch) | |
| tree | 646e6771c70bea163c80909567cd785ccd25f3f1 /src/components/profile/Content.tsx | |
| parent | 7ccb796e2cd25d48cbaee07c19b5f66e94859ba8 (diff) | |
updated helper function, cleaned up code, prevent friends navigation
Diffstat (limited to 'src/components/profile/Content.tsx')
| -rw-r--r-- | src/components/profile/Content.tsx | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 9fb6f79b..779e0525 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -38,22 +38,23 @@ import TaggsBar from '../taggs/TaggsBar'; const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => { const dispatch = useDispatch(); - - const {user = NO_USER, profile = NO_PROFILE} = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.user); + const state: RootState = useStore().getState(); + const { + user = NO_USER, + profile = NO_PROFILE, + } = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.user, + ); const {blockedUsers = EMPTY_PROFILE_PREVIEW_LIST} = useSelector( (state: RootState) => state.blocked, ); const {user: loggedInUser = NO_USER} = useSelector( (state: RootState) => state.user, ); - const state = useStore().getState(); /** * States */ - const [isFriend, setIsFriend] = useState<boolean>(false); const [isBlocked, setIsBlocked] = useState<boolean>(false); const [profileBodyHeight, setProfileBodyHeight] = useState(0); const [shouldBounce, setShouldBounce] = useState<boolean>(true); @@ -87,10 +88,6 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => { } }, [blockedUsers, user]); - useEffect(() => { - setIsFriend(profile.friendship_status === 'friends'); - }, [profile.friendship_status]); - /** * Handles a click on the block / unblock button. * loadFriends updates friends list for the logged in user @@ -151,16 +148,11 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => { onLayout, userXId, screenType, - isFriend, handleBlockUnblock, isBlocked, }} /> - {canViewProfile( - loggedInUser.userId === user.userId, - profile.is_private, - isFriend, - ) ? ( + {canViewProfile(state, userXId, screenType) ? ( <> <TaggsBar {...{y, profileBodyHeight, userXId, screenType}} |
