Implement API call for fetching an account's statuses
This commit is contained in:
parent
995a672270
commit
c754892156
|
@ -197,15 +197,20 @@ const ProfileJsx = ({ navigation }) => {
|
||||||
"@user_profile",
|
"@user_profile",
|
||||||
"@user_notifications",
|
"@user_notifications",
|
||||||
"@user_instance",
|
"@user_instance",
|
||||||
|
"@user_token",
|
||||||
])
|
])
|
||||||
.then(([profilePair, notifPair, domainPair]) => {
|
.then(([profilePair, notifPair, domainPair, tokenPair]) => {
|
||||||
profile = JSON.parse(profilePair[1]);
|
profile = JSON.parse(profilePair[1]);
|
||||||
notifs = JSON.parse(notifPair[1]);
|
notifs = JSON.parse(notifPair[1]);
|
||||||
domain = domainPair[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)) {
|
if(JSON.stringify(latestProfile) != JSON.stringify(profile)) {
|
||||||
profile = latestProfile
|
profile = latestProfile
|
||||||
}
|
}
|
||||||
|
@ -213,6 +218,7 @@ const ProfileJsx = ({ navigation }) => {
|
||||||
setState({...state,
|
setState({...state,
|
||||||
profile: profile,
|
profile: profile,
|
||||||
notifs: notifs,
|
notifs: notifs,
|
||||||
|
posts: posts,
|
||||||
loaded: true,
|
loaded: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -228,7 +234,7 @@ const ProfileJsx = ({ navigation }) => {
|
||||||
navigation = { navigation }
|
navigation = { navigation }
|
||||||
own = { true }
|
own = { true }
|
||||||
profile = { state.profile }
|
profile = { state.profile }
|
||||||
posts = { TEST_POSTS }
|
posts = { state.posts }
|
||||||
notifs = { state.notifs }/>
|
notifs = { state.notifs }/>
|
||||||
</ScreenWithTrayJsx>
|
</ScreenWithTrayJsx>
|
||||||
: <></>
|
: <></>
|
||||||
|
|
|
@ -76,6 +76,11 @@ export async function fetchProfile(domain, id) {
|
||||||
return resp.json();
|
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) {
|
export async function fetchFollowing(domain, id, token) {
|
||||||
const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token);
|
const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token);
|
||||||
return resp.json();
|
return resp.json();
|
||||||
|
|
Loading…
Reference in New Issue