From f5c12123aefe988b5092d6fba165ef17a1c7733b Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 24 Feb 2021 16:51:59 -0500 Subject: do not re-populate taggs --- src/components/taggs/TaggsBar.tsx | 63 +++++++++++----------- .../suggestedPeople/SuggestedPeopleScreen.tsx | 1 + src/services/SocialLinkingService.ts | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx index 05ee18bb..f952c53f 100644 --- a/src/components/taggs/TaggsBar.tsx +++ b/src/components/taggs/TaggsBar.tsx @@ -21,6 +21,7 @@ interface TaggsBarProps { userXId: string | undefined; screenType: ScreenType; whiteRing: boolean | undefined; + linkedSocials?: string[]; } const TaggsBar: React.FC = ({ y, @@ -28,6 +29,7 @@ const TaggsBar: React.FC = ({ userXId, screenType, whiteRing, + linkedSocials, }) => { let [taggs, setTaggs] = useState([]); let [taggsNeedUpdate, setTaggsNeedUpdate] = useState(true); @@ -57,49 +59,50 @@ const TaggsBar: React.FC = ({ */ useEffect(() => { const loadData = async () => { - getLinkedSocials(user.userId).then((linkedSocials) => { - const unlinkedSocials = SOCIAL_LIST.filter( - (s) => linkedSocials.indexOf(s) === -1, + const socials: string[] = linkedSocials + ? linkedSocials + : await getLinkedSocials(user.userId); + const unlinkedSocials = SOCIAL_LIST.filter( + (s) => socials.indexOf(s) === -1, + ); + let new_taggs = []; + let i = 0; + for (let social of socials) { + new_taggs.push( + , ); - let new_taggs = []; - let i = 0; - for (let social of linkedSocials) { + i++; + } + if (!userXId && !whiteRing) { + for (let social of unlinkedSocials) { new_taggs.push( , ); i++; } - if (!userXId && !whiteRing) { - for (let social of unlinkedSocials) { - new_taggs.push( - , - ); - i++; - } - } - setTaggs(new_taggs); - setTaggsNeedUpdate(false); - }); + } + setTaggs(new_taggs); + setTaggsNeedUpdate(false); }; if (user.userId) { loadData(); diff --git a/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx b/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx index 6cf792ef..a16cff89 100644 --- a/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx +++ b/src/screens/suggestedPeople/SuggestedPeopleScreen.tsx @@ -255,6 +255,7 @@ const SuggestedPeopleScreen: React.FC = () => { profileBodyHeight={0} screenType={screenType} whiteRing={true} + linkedSocials={data.social_links} /> diff --git a/src/services/SocialLinkingService.ts b/src/services/SocialLinkingService.ts index 1423c8c0..d1c5c2ff 100644 --- a/src/services/SocialLinkingService.ts +++ b/src/services/SocialLinkingService.ts @@ -203,7 +203,7 @@ export const getLinkedSocials: (user_id: string) => Promise = async ( }, }); if (response.status !== 200) { - throw 'Unable to fetch linked socials from server'; + return []; } const body = await response.json(); return body.linked_socials || []; -- cgit v1.2.3-70-g09d2