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_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 }/>
|
||||
</ScreenWithTrayJsx>
|
||||
: <></>
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue