Refresh profile from server and return after update
This commit is contained in:
@@ -256,16 +256,25 @@ let Profile = ({ navigation, route }) => {
|
||||
tag,
|
||||
});
|
||||
setLoading(true);
|
||||
API.getPosts(route.params.profileid).then((data) => {
|
||||
Promise.all([
|
||||
API.getUserProfile(route.params.profileid, true),
|
||||
API.getPosts(route.params.profileid),
|
||||
]).then(([profileObj, data]) => {
|
||||
const nextProfile = profileObj && profileObj._id ? profileObj : {};
|
||||
const profileData = nextProfile.profile || {};
|
||||
const safePosts = Array.isArray(data) ? data : [];
|
||||
setProfile(nextProfile);
|
||||
navigation.setOptions({ title: (profileData.firstName || "") + " " + (profileData.lastName || "") });
|
||||
setPosts(safePosts);
|
||||
storeProfilePosts(route.params.profileid, safePosts);
|
||||
setLoading(false);
|
||||
logProfile('refresh:end', {
|
||||
profileid: route.params.profileid,
|
||||
count: safePosts.length,
|
||||
cached: true,
|
||||
cached: false,
|
||||
});
|
||||
}).catch(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
}}
|
||||
/> :
|
||||
|
||||
Reference in New Issue
Block a user