From 6e054a927c390cbc6aba4185921397cdcd867e33 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 24 Mar 2021 11:25:58 -0400 Subject: cleaned up logic --- src/utils/users.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/users.ts b/src/utils/users.ts index d1f416e0..e11e8c78 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -103,12 +103,15 @@ export const userXInStore = ( * Abstracted the code to laod all socials out. * @param userId userId for whom socials should be fetched */ -export const loadAllSocialsForUser = async (userId: string) => { +export const loadAllSocialsForUser = async (userId: string, token?: string) => { + if (!token) { + token = (await AsyncStorage.getItem('token')) ?? ''; + } let socials = NO_SOCIAL_ACCOUNTS; try { let socialNeedsUpdate = INTEGRATED_SOCIAL_LIST; for (let socialType of socialNeedsUpdate) { - const social = await loadSocialPosts(userId, socialType); + const social = await loadSocialPosts(userId, socialType, token); socials = {...socials, [socialType]: social}; } return socials; @@ -165,4 +168,3 @@ export const defaultUserProfile = () => { const defaultImage = require('../assets/images/avatar-placeholder.png'); return defaultImage; }; - -- cgit v1.2.3-70-g09d2