diff options
Diffstat (limited to 'src/components/taggs/Tagg.tsx')
-rw-r--r-- | src/components/taggs/Tagg.tsx | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index 4e4987fb..5d26539b 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -17,13 +17,15 @@ import { registerNonIntegratedSocialLink, } from '../../services'; import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common'; -import {UserType} from '../../types'; +import {ScreenType, UserType} from '../../types'; import { ERROR_LINK, ERROR_UNABLE_TO_FIND_PROFILE, SUCCESS_LINK, } from '../../constants/strings'; -import {normalize} from '../../utils'; +import {canViewProfile, normalize} from '../../utils'; +import {RootState} from '../../store/rootReducer'; +import {useStore} from 'react-redux'; interface TaggProps { social: string; @@ -34,7 +36,7 @@ interface TaggProps { userXId: string | undefined; user: UserType; whiteRing: boolean | undefined; - allowNavigation?: boolean; + screenType: ScreenType; } const Tagg: React.FC<TaggProps> = ({ @@ -44,11 +46,12 @@ const Tagg: React.FC<TaggProps> = ({ setTaggsNeedUpdate, setSocialDataNeedUpdate, userXId, + screenType, user, whiteRing, - allowNavigation = true, }) => { const navigation = useNavigation(); + const state: RootState = useStore().getState(); const [modalVisible, setModalVisible] = useState(false); const youMayPass = isLinked || userXId; @@ -72,19 +75,21 @@ const Tagg: React.FC<TaggProps> = ({ 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 (canViewProfile(state, userXId, screenType)) { + if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { + navigation.navigate('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) { @@ -147,8 +152,7 @@ const Tagg: React.FC<TaggProps> = ({ <View style={whiteRing ? styles.spcontainer : styles.container}> <TouchableOpacity style={styles.iconTap} - onPress={modalOrAuthBrowserOrPass} - disabled={!allowNavigation}> + onPress={modalOrAuthBrowserOrPass}> <SocialIcon style={styles.icon} social={social} whiteRing /> {pickTheRightRingHere()} </TouchableOpacity> |