mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 16:34:54 +00:00
Profile picture upload added, QR code scan fix
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import {useMutation, useQueryClient} from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import storage from "@react-native-firebase/storage";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { Platform } from "react-native";
|
||||
import {Platform} from "react-native";
|
||||
|
||||
export const useChangeProfilePicture = () => {
|
||||
export const useChangeProfilePicture = (customUserId?: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
const { user, refreshProfileData } = useAuthContext();
|
||||
const {user, refreshProfileData} = useAuthContext();
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["changeProfilePicture"],
|
||||
@ -38,10 +38,12 @@ export const useChangeProfilePicture = () => {
|
||||
const downloadURL = await reference.getDownloadURL();
|
||||
console.log("Download URL:", downloadURL);
|
||||
|
||||
if(!customUserId) {
|
||||
await firestore()
|
||||
.collection("Profiles")
|
||||
.doc(user?.uid)
|
||||
.update({ pfp: downloadURL });
|
||||
.update({pfp: downloadURL});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Error uploading profile picture:", e);
|
||||
@ -50,8 +52,10 @@ export const useChangeProfilePicture = () => {
|
||||
},
|
||||
onSuccess: () => {
|
||||
// Invalidate queries to refresh profile data
|
||||
queryClient.invalidateQueries("Profiles");
|
||||
refreshProfileData();
|
||||
if (!customUserId) {
|
||||
queryClient.invalidateQueries("Profiles");
|
||||
refreshProfileData();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user