diff options
author | Ivan Chen <ivan@thetaggid.com> | 2020-10-22 17:42:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 17:42:29 -0400 |
commit | 52a3fe743e6122d157eaab3ad7bab0c70a96676b (patch) | |
tree | 564c5df3864a0d0fe09f7c18613d4cf5a1093170 /src/services/UserProfileService.ts | |
parent | 08f9aebbaef871629323767c93c9e54cea527bed (diff) |
[TMA-242] Twitter and Facebook Tagg View (#63)
* modified the way we store social media data, initial skeleton
* MVP? Twitter done?
* cleaned up some things
* forgot to lint and cleaned up some more code
* minor change to text display
* fixed some UI bug, linting, and minor adjustment to posts UI
* fixed a couple of things
* added DateLabel, Facebook taggs view, fixed minor stuff
* Some small changes for the PR
* removed unused Feed
Co-authored-by: Ashm Walia <ashmwalia@outlook.com>
Diffstat (limited to 'src/services/UserProfileService.ts')
-rw-r--r-- | src/services/UserProfileService.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 4c3af06a..59f9649a 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -6,10 +6,12 @@ import { AVATAR_PHOTO_ENDPOINT, COVER_PHOTO_ENDPOINT, GET_IG_POSTS_ENDPOINT, + GET_TWITTER_POSTS_ENDPOINT, } from '../constants'; import AsyncStorage from '@react-native-community/async-storage'; import RNFetchBlob from 'rn-fetch-blob'; +import {SocialAccountType} from 'src/types'; export const loadProfileInfo = async ( token: string, @@ -83,32 +85,32 @@ export const loadCover = async ( } }; -export const loadInstaPosts = async ( +export const loadSocialPosts = async ( token: string, userId: string, - callback: Function, + socialType: string, + endpoint: string, + socialAccounts: Record<string, SocialAccountType>, ) => { try { - const response = await fetch(GET_IG_POSTS_ENDPOINT + `${userId}/`, { + const response = await fetch(endpoint + `${userId}/`, { method: 'GET', headers: { Authorization: 'Token ' + token, }, }); - const status = response.status; - if (status === 200) { - let ig_posts = await response.json(); - callback(ig_posts); + if (response.status === 200) { + const body = await response.json(); + socialAccounts[socialType].handle = body.handle; + socialAccounts[socialType].posts = body.posts; + socialAccounts[socialType].profile_pic = body.profile_pic; } else { - callback([]); + throw new Error(await response.json()); } } catch (error) { console.log(error); - Alert.alert( - 'Something went wrong! ðŸ˜', - "Would you believe me if I told you that I don't know what happened?", - ); } + return socialAccounts; }; export const loadRecentlySearchedUsers = async (callback: Function) => { |