Gracefully handle backend failures in Expo app

This commit is contained in:
Adolfo Reyna
2026-02-20 19:25:38 -05:00
parent fe9fc8e3e4
commit 009f1ec792
14 changed files with 205 additions and 97 deletions

View File

@@ -24,7 +24,7 @@ let MenuView = ({ navigation }) => {
let getData = async () => {
const r = await API.getMyProfiles();
if (!subscribed) return;
setMyProfiles(r.profiles);
setMyProfiles(Array.isArray(r?.profiles) ? r.profiles : []);
}
getData();
return () => {
@@ -40,16 +40,17 @@ let MenuView = ({ navigation }) => {
//reloadAppAsync();
}
const profileLists = myProfiles.map((profile) => {
const profileInfo = profile?.profile || {};
const DefaultPhoto = "https://social.emmint.com/uploads/e6f9be6d665dc43417701bf16a90122c.png";
let photoUrl = profile.profile?.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto;
let photoUrl = profileInfo.photo ? 'https://social.emmint.com/' + profileInfo.photo : DefaultPhoto;
let icon = profile._id ? (!profile.isGroup ? "person-outline" : "group") : '';
icon = icon === "person-outline" && profile.subscription && profile.subscription > (new Date() - 0) ? "assignment-ind" : icon;
icon = icon === "group" && profile.isCourse ? "subscriptions" : icon;
icon = icon === "group" && profile.isPrivate ? "screen-lock-portrait" : icon;
return <>
<List.Item
title={profile.profile.firstName + " " + profile.profile.lastName}
description={profile.profile.description}
title={(profileInfo.firstName || "") + " " + (profileInfo.lastName || "")}
description={profileInfo.description || ""}
onPress={async () => {
await API.changeProfile(profile._id);
GlobalState.me = await API.getMe();
@@ -103,4 +104,4 @@ let MenuView = ({ navigation }) => {
)
}
export default MenuView;
export default MenuView;