Fix change profile photo
This commit is contained in:
@@ -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 = ()=>{
|
||||
<RadioButton.Item value="en" label="English"/>
|
||||
</RadioButton.Group>
|
||||
</View>
|
||||
<Button icon="photo" mode="outlined" onPress={pickImage} >{i18n.t("message.updatePhoto")}</Button>
|
||||
<Button icon="photo" mode="outlined" onPress={pickImage}>{!uploading ? i18n.t("message.updatePhoto"): "uploading"}</Button>
|
||||
<Divider />
|
||||
<View style={{paddingTop: 10}}>
|
||||
<Text style={{fontSize:20, padding: 5, color:"#666"}}>Preview:</Text>
|
||||
|
||||
Reference in New Issue
Block a user