aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/taggs/TaggsBar.tsx63
-rw-r--r--src/screens/suggestedPeople/SuggestedPeopleScreen.tsx1
-rw-r--r--src/services/SocialLinkingService.ts2
3 files changed, 35 insertions, 31 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();
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}
/>
<View style={styles.marginManager}>
<MutualFriends user={data.user} friends={data.mutual_friends} />
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<string[]> = async (
},
});
if (response.status !== 200) {
- throw 'Unable to fetch linked socials from server';
+ return [];
}
const body = await response.json();
return body.linked_socials || [];