From 641a98cd5d184efb5639952812f24c56c90e7f62 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 29 Mar 2021 14:18:00 -0400 Subject: code cleanup --- src/components/profile/Content.tsx | 1 - src/components/taggs/TaggsBar.tsx | 18 +++++++++--------- src/screens/suggestedPeople/SPBody.tsx | 5 ----- 3 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 779e0525..cf2b7d28 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -165,7 +165,6 @@ const Content: React.FC = ({y, userXId, screenType}) => { diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx index a9c428b2..567b58de 100644 --- a/src/components/taggs/TaggsBar.tsx +++ b/src/components/taggs/TaggsBar.tsx @@ -2,7 +2,7 @@ import React, {Fragment, useEffect, useState} from 'react'; import {StyleSheet} from 'react-native'; import Animated from 'react-native-reanimated'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; -import {useDispatch, useSelector} from 'react-redux'; +import {useDispatch, useSelector, useStore} from 'react-redux'; import { INTEGRATED_SOCIAL_LIST, PROFILE_CUTOUT_BOTTOM_Y, @@ -12,6 +12,7 @@ import {getLinkedSocials} from '../../services'; import {loadIndividualSocial, updateSocial} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; +import {canViewProfile} from '../../utils'; import Tagg from './Tagg'; const {View, ScrollView, interpolate, Extrapolate} = Animated; @@ -22,7 +23,6 @@ interface TaggsBarProps { screenType: ScreenType; whiteRing: boolean | undefined; linkedSocials?: string[]; - allowNavigation?: boolean; } const TaggsBar: React.FC = ({ y, @@ -31,14 +31,14 @@ const TaggsBar: React.FC = ({ screenType, whiteRing, linkedSocials, - allowNavigation = true, }) => { let [taggs, setTaggs] = useState([]); let [taggsNeedUpdate, setTaggsNeedUpdate] = useState(true); - - const {user} = userXId - ? useSelector((state: RootState) => state.userX[screenType][userXId]) - : useSelector((state: RootState) => state.user); + const {user} = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.user, + ); + const state: RootState = useStore().getState(); + const allowTaggsNavigation = canViewProfile(state, userXId, screenType); const dispatch = useDispatch(); @@ -81,7 +81,7 @@ const TaggsBar: React.FC = ({ setTaggsNeedUpdate={setTaggsNeedUpdate} setSocialDataNeedUpdate={handleSocialUpdate} whiteRing={whiteRing ? whiteRing : undefined} - allowNavigation={allowNavigation} + allowNavigation={allowTaggsNavigation} />, ); i++; @@ -99,7 +99,7 @@ const TaggsBar: React.FC = ({ userXId={userXId} user={user} whiteRing={whiteRing ? whiteRing : undefined} - allowNavigation={allowNavigation} + allowNavigation={allowTaggsNavigation} />, ); i++; diff --git a/src/screens/suggestedPeople/SPBody.tsx b/src/screens/suggestedPeople/SPBody.tsx index 297f76c0..824f8b1c 100644 --- a/src/screens/suggestedPeople/SPBody.tsx +++ b/src/screens/suggestedPeople/SPBody.tsx @@ -166,11 +166,6 @@ const SPBody: React.FC = ({ screenType={screenType} whiteRing={true} linkedSocials={social_links} - allowNavigation={canViewProfile( - state, - loggedInUserId === user.id ? undefined : user.id, - screenType, - )} /> -- cgit v1.2.3-70-g09d2