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

@@ -7,7 +7,9 @@ import FollowButton from './basics/FollowButton';
const DefaultPhoto = "https://social.emmint.com/uploads/e6f9be6d665dc43417701bf16a90122c.png";
const ProfileHeader = ({ profileObj }) => {
let photoUrl = profileObj.profile && profileObj.profile.photo ? 'https://social.emmint.com/' + profileObj.profile.photo + '?width=1000&height=1000' : DefaultPhoto;
const safeProfileObj = profileObj || {};
const safeProfile = safeProfileObj.profile || {};
let photoUrl = safeProfile.photo ? 'https://social.emmint.com/' + safeProfile.photo + '?width=1000&height=1000' : DefaultPhoto;
return (
<>
<Card elevation={3}>
@@ -16,9 +18,9 @@ const ProfileHeader = ({ profileObj }) => {
}} />
<Card.Content style={{}}>
<Title style={{ position: "absolute", top: -60, left: 10, backgroundColor: "rgba(255,255,255,0.4)", padding: 10 }}>
<UserName profileid={profileObj._id} />
<UserName profileid={safeProfileObj._id} />
</Title>
<Paragraph style={{ paddingTop: 10 }}>{profileObj.profile.description}</Paragraph>
<Paragraph style={{ paddingTop: 10 }}>{safeProfile.description || ""}</Paragraph>
<View style={{
position: "absolute",
top: -290,
@@ -29,7 +31,7 @@ const ProfileHeader = ({ profileObj }) => {
borderRadius: 25,
opacity: 0.7
}}>
<FollowButton profile={profileObj} />
<FollowButton profile={safeProfileObj} />
</View>
<View style={{
position: "absolute",
@@ -43,8 +45,8 @@ const ProfileHeader = ({ profileObj }) => {
}}>
<Button icon="ios-share" labelStyle={{ fontSize: 24, paddingTop:10 }} onPress={() => {
Share.share({
message: "https://social.emmint.com/feed/" + profileObj._id,
title: profileObj.profile.firstName + " " + profileObj.profile.lastName
message: "https://social.emmint.com/feed/" + safeProfileObj._id,
title: (safeProfile.firstName || "") + " " + (safeProfile.lastName || "")
});
}}></Button>
</View>
@@ -63,4 +65,4 @@ const ProfileHeader = ({ profileObj }) => {
}
export default React.memo(ProfileHeader);
export default React.memo(ProfileHeader);