Implement API call for fetching an account's statuses

This commit is contained in:
Nat 2021-05-05 17:52:03 -03:00
parent 995a672270
commit c754892156
2 changed files with 15 additions and 4 deletions

View File

@ -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>
: <></>

View File

@ -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();