mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
- Fixed issue with uploading images for other users
This commit is contained in:
@ -50,7 +50,7 @@ const UpdateUserDialog = ({ open, handleClose, profileData }: Props) => {
|
|||||||
|
|
||||||
const { mutateAsync: updateUserData } = useUpdateUserData();
|
const { mutateAsync: updateUserData } = useUpdateUserData();
|
||||||
const { mutateAsync: updateSubUser } = useUpdateSubUser();
|
const { mutateAsync: updateSubUser } = useUpdateSubUser();
|
||||||
const { mutateAsync: changeProfilePicture } = useChangeProfilePicture();
|
const { mutateAsync: changeProfilePicture } = useChangeProfilePicture(profileData?.uid);
|
||||||
|
|
||||||
const handleUpdateUserData = async () => {
|
const handleUpdateUserData = async () => {
|
||||||
await updateSubUser({
|
await updateSubUser({
|
||||||
@ -150,7 +150,7 @@ const UpdateUserDialog = ({ open, handleClose, profileData }: Props) => {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
<TouchableOpacity onPress={pickImage}>
|
<TouchableOpacity onPress={pickImage}>
|
||||||
<Text style={styles.photoSet} color="#50be0c" onPress={pickImage}>
|
<Text style={styles.photoSet} color="#50be0c">
|
||||||
{profileData?.pfp ? "Change" : "Add"} Photo
|
{profileData?.pfp ? "Change" : "Add"} Photo
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@ -39,10 +39,15 @@ export const useChangeProfilePicture = (customUserId?: string) => {
|
|||||||
console.log("Download URL:", downloadURL);
|
console.log("Download URL:", downloadURL);
|
||||||
|
|
||||||
if(!customUserId) {
|
if(!customUserId) {
|
||||||
await firestore()
|
await firestore()
|
||||||
.collection("Profiles")
|
.collection("Profiles")
|
||||||
.doc(user?.uid)
|
.doc(user?.uid)
|
||||||
.update({pfp: downloadURL});
|
.update({pfp: downloadURL});
|
||||||
|
} else {
|
||||||
|
await firestore()
|
||||||
|
.collection("Profiles")
|
||||||
|
.doc(customUserId)
|
||||||
|
.update({pfp: downloadURL});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -55,6 +60,8 @@ export const useChangeProfilePicture = (customUserId?: string) => {
|
|||||||
if (!customUserId) {
|
if (!customUserId) {
|
||||||
queryClient.invalidateQueries({queryKey: ["Profiles"]});
|
queryClient.invalidateQueries({queryKey: ["Profiles"]});
|
||||||
refreshProfileData();
|
refreshProfileData();
|
||||||
|
} else {
|
||||||
|
queryClient.invalidateQueries({queryKey: ["Profiles"]});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user