diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-09 19:55:26 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-09 19:55:26 -0400 |
commit | 0a480048b41a80e8569ce57064d1b9716c3d25e3 (patch) | |
tree | 4f1118560c10dcdfa32e99d2b73c3d7814d7904d /src/components/taggs/Tagg.tsx | |
parent | 17de7d8312b10f84af2178f769ff92bf96ab47f5 (diff) | |
parent | 9d5ad9bea36c0b2abffd04b25126d18158017137 (diff) |
Merge branch 'master' into tma784-style-message-input
# Conflicts:
# src/screens/chat/ChatListScreen.tsx
# src/screens/chat/ChatScreen.tsx
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> |