Refresh profile from server and return after update

This commit is contained in:
Adolfo Reyna
2026-02-20 22:10:44 -05:00
parent ffb8f9bec5
commit cc9ca1d075
2 changed files with 26 additions and 10 deletions

View File

@@ -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);
});
}}
/> :