From 792115326fc6af583f422082537885bc8061d051 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 8 Dec 2020 23:17:23 -0500 Subject: [TMA-410] Edit Non-Integrated Socials (#126) * removed refs, added KB avoidance, UI done * missed some things * now parsing response correctly from backend * fixed naming * now allow empty strings to un-link a social * hide field if empty, allow empty string, fixed taggs bar not updating bug * Fix bug where non integrated socials do not show up on edit profile page Co-authored-by: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> Co-authored-by: Ashm Walia --- src/components/taggs/Tagg.tsx | 5 +++-- src/components/taggs/TaggsBar.tsx | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index 086b3c87..8158cbac 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -26,7 +26,7 @@ interface TaggProps { isLinked: boolean; isIntegrated: boolean; setTaggsNeedUpdate: (_: boolean) => void; - setSocialDataNeedUpdate: (_: string) => void; + setSocialDataNeedUpdate: (social: string, username: string) => void; userXId: string; screenType: ScreenType; } @@ -84,7 +84,7 @@ const Tagg: React.FC = ({ if (isIntegrated) { handlePressForAuthBrowser(social).then((success) => { setTaggsNeedUpdate(success); - if (success) setSocialDataNeedUpdate(social); + if (success) setSocialDataNeedUpdate(social, ''); }); } else { setModalVisible(true); @@ -112,6 +112,7 @@ const Tagg: React.FC = ({ if (await registerNonIntegratedSocialLink(social, username)) { Alert.alert(`Successfully linked ${social} 🎉`); setTaggsNeedUpdate(true); + setSocialDataNeedUpdate(social, username); } else { // If we display too fast the alert will get dismissed with the modal setTimeout(() => { diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx index 12e4b93a..082743d0 100644 --- a/src/components/taggs/TaggsBar.tsx +++ b/src/components/taggs/TaggsBar.tsx @@ -12,7 +12,7 @@ import {StatusBarHeight} from '../../utils'; import Tagg from './Tagg'; import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; -import {loadIndividualSocial} from '../../store/actions'; +import {loadIndividualSocial, updateSocial} from '../../store/actions'; const {View, ScrollView, interpolate, Extrapolate} = Animated; interface TaggsBarProps { @@ -38,10 +38,15 @@ const TaggsBar: React.FC = ({ /** * Updates the individual social that needs update + * If username is empty, update nonintegrated socials like Snapchat and TikTok * @param socialType Type of the social that needs update */ - const handleSocialUpdate = (socialType: string) => { - dispatch(loadIndividualSocial(user.userId, socialType)); + const handleSocialUpdate = (socialType: string, username: string) => { + if (username !== '') { + dispatch(updateSocial(socialType, username)); + } else { + dispatch(loadIndividualSocial(user.userId, socialType)); + } }; /** -- cgit v1.2.3-70-g09d2