aboutsummaryrefslogtreecommitdiff
path: root/src/components/taggs/TaggsBar.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-24 20:56:49 -0500
committerGitHub <noreply@github.com>2021-02-24 20:56:49 -0500
commit5c5e53799dde337ca9baa298c218f5cf02764226 (patch)
treeee9adab51a8fd27f65804c1e707102760b061220 /src/components/taggs/TaggsBar.tsx
parent1cd6a6cc2adc103366b63f84175f5006a72b2091 (diff)
parentf5c12123aefe988b5092d6fba165ef17a1c7733b (diff)
Merge pull request #263 from IvanIFChen/tma665-sp-taggsbar-flickering
[TMA-665] SP Taggs bar flickering
Diffstat (limited to 'src/components/taggs/TaggsBar.tsx')
-rw-r--r--src/components/taggs/TaggsBar.tsx63
1 files changed, 33 insertions, 30 deletions
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<TaggsBarProps> = ({
y,
@@ -28,6 +29,7 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
userXId,
screenType,
whiteRing,
+ linkedSocials,
}) => {
let [taggs, setTaggs] = useState<Object[]>([]);
let [taggsNeedUpdate, setTaggsNeedUpdate] = useState(true);
@@ -57,49 +59,50 @@ const TaggsBar: React.FC<TaggsBarProps> = ({
*/
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(
+ <Tagg
+ key={i}
+ social={social}
+ userXId={userXId}
+ user={user}
+ isLinked={true}
+ isIntegrated={INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1}
+ setTaggsNeedUpdate={setTaggsNeedUpdate}
+ setSocialDataNeedUpdate={handleSocialUpdate}
+ whiteRing={whiteRing ? whiteRing : undefined}
+ />,
);
- let new_taggs = [];
- let i = 0;
- for (let social of linkedSocials) {
+ i++;
+ }
+ if (!userXId && !whiteRing) {
+ for (let social of unlinkedSocials) {
new_taggs.push(
<Tagg
key={i}
social={social}
- userXId={userXId}
- user={user}
- isLinked={true}
+ isLinked={false}
isIntegrated={INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1}
setTaggsNeedUpdate={setTaggsNeedUpdate}
setSocialDataNeedUpdate={handleSocialUpdate}
+ userXId={userXId}
+ user={user}
whiteRing={whiteRing ? whiteRing : undefined}
/>,
);
i++;
}
- if (!userXId && !whiteRing) {
- for (let social of unlinkedSocials) {
- new_taggs.push(
- <Tagg
- key={i}
- social={social}
- isLinked={false}
- isIntegrated={INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1}
- setTaggsNeedUpdate={setTaggsNeedUpdate}
- setSocialDataNeedUpdate={handleSocialUpdate}
- userXId={userXId}
- user={user}
- whiteRing={whiteRing ? whiteRing : undefined}
- />,
- );
- i++;
- }
- }
- setTaggs(new_taggs);
- setTaggsNeedUpdate(false);
- });
+ }
+ setTaggs(new_taggs);
+ setTaggsNeedUpdate(false);
};
if (user.userId) {
loadData();