diff options
author | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:21:59 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:21:59 -0400 |
commit | 96477697afe4dd92ce68f0f778decbca30d83e77 (patch) | |
tree | a7e09d11f5138153331f97963bf880e6c5f6aefa /src/utils/users.ts | |
parent | fc9564f27ef7b1fd71a25d2081d910e18106035a (diff) |
async social load
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r-- | src/utils/users.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index e11e8c78..f54d461c 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -109,10 +109,16 @@ export const loadAllSocialsForUser = async (userId: string, token?: string) => { } let socials = NO_SOCIAL_ACCOUNTS; try { - let socialNeedsUpdate = INTEGRATED_SOCIAL_LIST; - for (let socialType of socialNeedsUpdate) { - const social = await loadSocialPosts(userId, socialType, token); - socials = {...socials, [socialType]: social}; + const fetchedSocials = await Promise.all( + INTEGRATED_SOCIAL_LIST.map((socialType) => + loadSocialPosts(userId, socialType, token).then((data) => ({ + key: socialType, + data, + })), + ), + ); + for (const fetchedSocial of fetchedSocials) { + socials = {...socials, [fetchedSocial.key]: fetchedSocial.data}; } return socials; } catch (error) { |