diff --git a/src/components/pages/profile.js b/src/components/pages/profile.js index d0171a9..fe118eb 100644 --- a/src/components/pages/profile.js +++ b/src/components/pages/profile.js @@ -197,15 +197,20 @@ const ProfileJsx = ({ navigation }) => { "@user_profile", "@user_notifications", "@user_instance", + "@user_token", ]) - .then(([profilePair, notifPair, domainPair]) => { + .then(([profilePair, notifPair, domainPair, tokenPair]) => { profile = JSON.parse(profilePair[1]); notifs = JSON.parse(notifPair[1]); domain = domainPair[1]; + accessToken = JSON.parse(tokenPair[1]).access_token; - return requests.fetchProfile(domain, profile.id); + return Promise.all([ + requests.fetchProfile(domain, profile.id), + requests.fetchAccountStatuses(domain, profile.id, accessToken), + ]); }) - .then(latestProfile => { + .then(([latestProfile, posts]) => { if(JSON.stringify(latestProfile) != JSON.stringify(profile)) { profile = latestProfile } @@ -213,6 +218,7 @@ const ProfileJsx = ({ navigation }) => { setState({...state, profile: profile, notifs: notifs, + posts: posts, loaded: true, }); }); @@ -228,7 +234,7 @@ const ProfileJsx = ({ navigation }) => { navigation = { navigation } own = { true } profile = { state.profile } - posts = { TEST_POSTS } + posts = { state.posts } notifs = { state.notifs }/> : <> diff --git a/src/requests.js b/src/requests.js index 5bdacfe..1283880 100644 --- a/src/requests.js +++ b/src/requests.js @@ -76,6 +76,11 @@ export async function fetchProfile(domain, id) { return resp.json(); } +export async function fetchAccountStatuses(domain, id, token) { + const resp = await get(`https://${domain}/api/v1/accounts/${id}/statuses`, token); + return resp.json(); +} + export async function fetchFollowing(domain, id, token) { const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token); return resp.json();