From 64f8829ab55bfe6851f10ca933043877769c56bf Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 26 Mar 2021 17:28:23 -0400 Subject: show taggsbar, prevent taggsbar navigation on profile and SP --- src/components/taggs/Tagg.tsx | 30 +++++++++++++++++------------- src/components/taggs/TaggsBar.tsx | 4 ++++ 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src/components/taggs') diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index 547a77cb..ae9ab091 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -34,6 +34,7 @@ interface TaggProps { userXId: string | undefined; user: UserType; whiteRing: boolean | undefined; + allowNavigation?: boolean; } const Tagg: React.FC = ({ @@ -45,6 +46,7 @@ const Tagg: React.FC = ({ userXId, user, whiteRing, + allowNavigation = true, }) => { const navigation = useNavigation(); const [modalVisible, setModalVisible] = useState(false); @@ -70,19 +72,21 @@ const Tagg: React.FC = ({ const modalOrAuthBrowserOrPass = async () => { if (youMayPass) { - if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { - navigation.push('SocialMediaTaggs', { - socialMediaType: social, - userXId, - }); - } else { - getNonIntegratedURL(social, user.userId).then((socialURL) => { - if (socialURL) { - Linking.openURL(socialURL); - } else { - Alert.alert(ERROR_UNABLE_TO_FIND_PROFILE); - } - }); + if (allowNavigation) { + if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { + navigation.push('SocialMediaTaggs', { + socialMediaType: social, + userXId, + }); + } else { + getNonIntegratedURL(social, user.userId).then((socialURL) => { + if (socialURL) { + Linking.openURL(socialURL); + } else { + Alert.alert(ERROR_UNABLE_TO_FIND_PROFILE); + } + }); + } } } else { if (isIntegrated) { diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx index f952c53f..a9c428b2 100644 --- a/src/components/taggs/TaggsBar.tsx +++ b/src/components/taggs/TaggsBar.tsx @@ -22,6 +22,7 @@ interface TaggsBarProps { screenType: ScreenType; whiteRing: boolean | undefined; linkedSocials?: string[]; + allowNavigation?: boolean; } const TaggsBar: React.FC = ({ y, @@ -30,6 +31,7 @@ const TaggsBar: React.FC = ({ screenType, whiteRing, linkedSocials, + allowNavigation = true, }) => { let [taggs, setTaggs] = useState([]); let [taggsNeedUpdate, setTaggsNeedUpdate] = useState(true); @@ -79,6 +81,7 @@ const TaggsBar: React.FC = ({ setTaggsNeedUpdate={setTaggsNeedUpdate} setSocialDataNeedUpdate={handleSocialUpdate} whiteRing={whiteRing ? whiteRing : undefined} + allowNavigation={allowNavigation} />, ); i++; @@ -96,6 +99,7 @@ const TaggsBar: React.FC = ({ userXId={userXId} user={user} whiteRing={whiteRing ? whiteRing : undefined} + allowNavigation={allowNavigation} />, ); i++; -- cgit v1.2.3-70-g09d2 From 8e4fc71e625e8818773ebfa3d93bbee32b3ffe99 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 29 Mar 2021 14:02:44 -0400 Subject: disabled press animation --- src/components/taggs/Tagg.tsx | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/components/taggs') diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index ae9ab091..4e4987fb 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -72,21 +72,19 @@ const Tagg: React.FC = ({ const modalOrAuthBrowserOrPass = async () => { if (youMayPass) { - if (allowNavigation) { - if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { - navigation.push('SocialMediaTaggs', { - socialMediaType: social, - userXId, - }); - } else { - getNonIntegratedURL(social, user.userId).then((socialURL) => { - if (socialURL) { - Linking.openURL(socialURL); - } else { - Alert.alert(ERROR_UNABLE_TO_FIND_PROFILE); - } - }); - } + if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { + navigation.push('SocialMediaTaggs', { + socialMediaType: social, + userXId, + }); + } else { + getNonIntegratedURL(social, user.userId).then((socialURL) => { + if (socialURL) { + Linking.openURL(socialURL); + } else { + Alert.alert(ERROR_UNABLE_TO_FIND_PROFILE); + } + }); } } else { if (isIntegrated) { @@ -149,7 +147,8 @@ const Tagg: React.FC = ({ + onPress={modalOrAuthBrowserOrPass} + disabled={!allowNavigation}> {pickTheRightRingHere()} -- cgit v1.2.3-70-g09d2 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/components/taggs') 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