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 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'src/components') 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(); -- cgit v1.2.3-70-g09d2