From c2f4a459c97e51e2759b23cd9d39953114d6561d Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Thu, 24 Aug 2023 23:11:47 -0400 Subject: [PATCH] Fix change profile photo --- Views/ProfileSettings.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Views/ProfileSettings.js b/Views/ProfileSettings.js index 92a01ee..c80e576 100644 --- a/Views/ProfileSettings.js +++ b/Views/ProfileSettings.js @@ -22,26 +22,30 @@ let ProfileSettings = ()=>{ const [photoUrl, setphotoUrl] = React.useState(viewer.profile.photo); const [updateKey, setUpdateKey] = React.useState(0); const [description, setDescription] = React.useState(viewer.profile.description); + const [uploading, setUploading] = React.useState(false); const pickImage = async () => { + if(uploading) return; // No permissions request is necessary for launching the image library let result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, allowsEditing: true, aspect: [4, 3], - quality: 0.2, + quality: 0.5, //allowsMultipleSelection: true, }); if (!result.canceled) { + setUploading(true); setPhoto(result); let newPhotoURL = await handleUploadPhoto(result.assets[0]); if(newPhotoURL !== ""){ setphotoUrl(newPhotoURL); GlobalState.me.profile.photo = newPhotoURL; - viewer.profile.photo = newPhotoURL; + updateProfile() setUpdateKey(updateKey + 1); } setPhoto(null); + setUploading(false); } }; @@ -88,7 +92,7 @@ let ProfileSettings = ()=>{ GlobalState.me.profile.firstName = name; GlobalState.me.profile.lastName = lastName; GlobalState.me.profile.description = description; - API.updateMyProfile(viewer.profile, viewer.data); + API.updateMyProfile(GlobalState.me.profile, viewer.data); setUpdateKey(updateKey+1); } @@ -130,7 +134,7 @@ let ProfileSettings = ()=>{ - + Preview: