diff options
Diffstat (limited to 'src/components/taggs/Tagg.tsx')
-rw-r--r-- | src/components/taggs/Tagg.tsx | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index 9f8fafd1..086b3c87 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -1,5 +1,5 @@ import {useNavigation} from '@react-navigation/native'; -import React, {Fragment, useContext, useState} from 'react'; +import React, {Fragment, useContext, useEffect, useState} from 'react'; import {Alert, Linking, StyleSheet, TouchableOpacity, View} from 'react-native'; import PurpleRingPlus from '../../assets/icons/purple_ring+.svg'; import PurpleRing from '../../assets/icons/purple_ring.svg'; @@ -17,36 +17,35 @@ import { registerNonIntegratedSocialLink, } from '../../services'; import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common'; -import {AuthContext, ProfileContext} from '../../routes'; +import {useSelector} from 'react-redux'; +import {RootState} from '../../store/rootreducer'; +import {ScreenType} from '../../types'; interface TaggProps { social: string; - isProfileView: boolean; isLinked: boolean; isIntegrated: boolean; setTaggsNeedUpdate: (_: boolean) => void; - setSocialDataNeedUpdate: (_: string[]) => void; - userId: string; + setSocialDataNeedUpdate: (_: string) => void; + userXId: string; + screenType: ScreenType; } const Tagg: React.FC<TaggProps> = ({ social, - isProfileView, isLinked, isIntegrated, setTaggsNeedUpdate, setSocialDataNeedUpdate, - userId, + userXId, + screenType, }) => { const navigation = useNavigation(); const [modalVisible, setModalVisible] = useState(false); - const youMayPass = isLinked || isProfileView; - const { - profile: {name}, - socialAccounts, - avatar, - } = isProfileView ? useContext(ProfileContext) : useContext(AuthContext); - + const youMayPass = isLinked || userXId; + const {user} = userXId + ? useSelector((state: RootState) => state.userX[screenType][userXId]) + : useSelector((state: RootState) => state.user); /* case isProfileView: case linked: @@ -62,7 +61,7 @@ const Tagg: React.FC<TaggProps> = ({ show auth browser case !integrated_social: show modal - Tagg's "Tagg" will use the Ring instead of PurpleRing + Tagg's "Tagg" will use the Ring instead of PurpleRing */ const modalOrAuthBrowserOrPass = async () => { @@ -70,14 +69,10 @@ const Tagg: React.FC<TaggProps> = ({ if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) { navigation.push('SocialMediaTaggs', { socialMediaType: social, - isProfileView: isProfileView, - userId: userId, - name: name, - accountData: socialAccounts[social], - avatar: avatar, + userXId, }); } else { - getNonIntegratedURL(social, userId).then((socialURL) => { + getNonIntegratedURL(social, user.userId).then((socialURL) => { if (socialURL) { Linking.openURL(socialURL); } else { @@ -89,7 +84,7 @@ const Tagg: React.FC<TaggProps> = ({ if (isIntegrated) { handlePressForAuthBrowser(social).then((success) => { setTaggsNeedUpdate(success); - setSocialDataNeedUpdate(success ? [social] : []); + if (success) setSocialDataNeedUpdate(social); }); } else { setModalVisible(true); @@ -127,7 +122,7 @@ const Tagg: React.FC<TaggProps> = ({ return ( <> - {isProfileView && !isLinked ? ( + {userXId && !isLinked ? ( <Fragment /> ) : ( <> |