mirror of
https://github.com/urosran/cally.git
synced 2025-07-09 22:57:16 +00:00
Fixes
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
module.exports = function (api) {
|
||||
const env = process.env.NODE_ENV;
|
||||
api.cache(true);
|
||||
let plugins = []
|
||||
|
||||
if (babelEnv !== 'development') {
|
||||
let plugins = [];
|
||||
|
||||
if (env !== 'development') {
|
||||
plugins.push('transform-remove-console');
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ export const AuthContextProvider: FC<{ children: ReactNode }> = ({children}) =>
|
||||
|
||||
useEffect(() => {
|
||||
const handleNotification = async (notification: Notifications.Notification) => {
|
||||
queryClient.invalidateQueries(["notifications"]);
|
||||
queryClient.invalidateQueries({queryKey: ["notifications"]});
|
||||
};
|
||||
|
||||
const sub = Notifications.addNotificationReceivedListener(handleNotification);
|
||||
|
@ -53,7 +53,7 @@ export const useChangeProfilePicture = (customUserId?: string) => {
|
||||
onSuccess: () => {
|
||||
// Invalidate queries to refresh profile data
|
||||
if (!customUserId) {
|
||||
queryClient.invalidateQueries("Profiles");
|
||||
queryClient.invalidateQueries({queryKey: ["Profiles"]});
|
||||
refreshProfileData();
|
||||
}
|
||||
},
|
||||
|
@ -83,7 +83,7 @@ export const useCreateEventsFromProvider = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("events");
|
||||
queryClient.invalidateQueries({queryKey: ["events"]});
|
||||
}
|
||||
});
|
||||
};
|
@ -1,16 +1,15 @@
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {useMutation, useQueryClient} from "@tanstack/react-query";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import { IFeedback } from "@/contexts/FeedbackContext";
|
||||
|
||||
export const useCreateFeedback = () => {
|
||||
const {user: currentUser, profileData} = useAuthContext()
|
||||
const queryClients = useQueryClient()
|
||||
const { user: currentUser } = useAuthContext();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["createFeedback"],
|
||||
mutationFn: async (feedback: Partial<IFeedback>) => {
|
||||
try {
|
||||
if (feedback.id) {
|
||||
const snapshot = await firestore()
|
||||
.collection("Feedbacks")
|
||||
@ -25,23 +24,21 @@ export const useCreateFeedback = () => {
|
||||
.set({
|
||||
...feedback,
|
||||
creatorId: currentUser?.uid,
|
||||
}, {merge: true});
|
||||
}, { merge: true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const newDoc = firestore().collection('Feedbacks').doc();
|
||||
await firestore()
|
||||
.collection("Feedbacks")
|
||||
.add({...feedback, id: newDoc.id, creatorId: currentUser?.uid});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
.add({ ...feedback, id: newDoc.id, creatorId: currentUser?.uid });
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("feedbacks")
|
||||
queryClient.invalidateQueries({ queryKey: ["feedbacks"] });
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateFeedbacksFromProvider = () => {
|
||||
const { user: currentUser } = useAuthContext();
|
||||
@ -50,10 +47,7 @@ export const useCreateFeedbacksFromProvider = () => {
|
||||
return useMutation({
|
||||
mutationKey: ["createFeedbacksFromProvider"],
|
||||
mutationFn: async (feedbackDataArray: Partial<IFeedback>[]) => {
|
||||
try {
|
||||
const promises = feedbackDataArray.map(async (feedbackData) => {
|
||||
console.log("Processing FeedbackData: ", feedbackData);
|
||||
|
||||
const snapshot = await firestore()
|
||||
.collection("Feedbacks")
|
||||
.where("id", "==", feedbackData.id)
|
||||
@ -63,23 +57,19 @@ export const useCreateFeedbacksFromProvider = () => {
|
||||
return firestore()
|
||||
.collection("Feedbacks")
|
||||
.add({ ...feedbackData, creatorId: currentUser?.uid });
|
||||
} else {
|
||||
}
|
||||
|
||||
const docId = snapshot.docs[0].id;
|
||||
return firestore()
|
||||
.collection("Feedbacks")
|
||||
.doc(docId)
|
||||
.set({ ...feedbackData, creatorId: currentUser?.uid }, { merge: true });
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
} catch (e) {
|
||||
console.error("Error creating/updating feedbacks: ", e);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("feedbacks");
|
||||
queryClient.invalidateQueries({ queryKey: ["feedbacks"] });
|
||||
}
|
||||
});
|
||||
};
|
@ -1,26 +1,30 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import {IGrocery} from "@/hooks/firebase/types/groceryData";
|
||||
import { IGrocery } from "@/hooks/firebase/types/groceryData";
|
||||
|
||||
export const useCreateGrocery = () => {
|
||||
const { user: currentUser, profileData } = useAuthContext();
|
||||
const queryClients = useQueryClient();
|
||||
const queryClient = useQueryClient();
|
||||
const groceriesKey = ["groceries"];
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["createGrocery"],
|
||||
mutationFn: async (groceryData: Partial<IGrocery>) => {
|
||||
try {
|
||||
mutationFn: (groceryData: Partial<IGrocery>) => {
|
||||
const newDoc = firestore().collection('Groceries').doc();
|
||||
await firestore()
|
||||
return firestore()
|
||||
.collection("Groceries")
|
||||
.add({...groceryData, id: newDoc.id, familyId: profileData?.familyId, creatorId: currentUser?.uid})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
.add({
|
||||
...groceryData,
|
||||
id: newDoc.id,
|
||||
familyId: profileData?.familyId,
|
||||
creatorId: currentUser?.uid
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("groceries")
|
||||
return queryClient.invalidateQueries({
|
||||
queryKey: groceriesKey,
|
||||
exact: true
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
@ -42,7 +42,7 @@ export const useCreateNote = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("braindumps");
|
||||
queryClients.invalidateQueries({queryKey: ["braindumps"]});
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -85,7 +85,7 @@ export const useCreateNotesFromProvider = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("braindumps");
|
||||
queryClient.invalidateQueries({queryKey: ["braindumps"]});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ export const useCreateTodo = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("todos")
|
||||
queryClients.invalidateQueries({queryKey: ["todos"]})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export const useDeleteEvent = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("events");
|
||||
queryClient.invalidateQueries({queryKey: ["events"]});
|
||||
}
|
||||
});
|
||||
};
|
@ -39,7 +39,7 @@ export const useDeleteFeedback = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("feedbacks");
|
||||
queryClient.invalidateQueries({queryKey: ["feedbacks"]});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ export const useDeleteGrocery = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("groceries");
|
||||
queryClient.invalidateQueries({queryKey: ["groceries"]});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ export const useDeleteNote = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("braindumps");
|
||||
queryClient.invalidateQueries({queryKey: ["braindumps"]});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -1,11 +1,12 @@
|
||||
import {useMutation, useQueryClient} from "@tanstack/react-query";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import {Notification} from "@/hooks/firebase/useGetNotifications";
|
||||
import { Notification } from "@/hooks/firebase/useGetNotifications";
|
||||
|
||||
export const useDeleteNotification = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const {user} = useAuthContext();
|
||||
const { user } = useAuthContext();
|
||||
const notificationsKey = ["notifications", user?.uid];
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
@ -15,23 +16,24 @@ export const useDeleteNotification = () => {
|
||||
.delete();
|
||||
},
|
||||
onMutate: async (deletedId) => {
|
||||
await queryClient.cancelQueries(["notifications", user?.uid]);
|
||||
await queryClient.cancelQueries({ queryKey: notificationsKey });
|
||||
|
||||
const previousNotifications = queryClient.getQueryData<Notification[]>(["notifications", user?.uid]);
|
||||
const previousNotifications = queryClient.getQueryData<Notification[]>(notificationsKey);
|
||||
|
||||
queryClient.setQueryData<Notification[]>(["notifications", user?.uid], (old) =>
|
||||
old?.filter((notification) => notification?.id! !== deletedId) ?? []
|
||||
queryClient.setQueryData<Notification[]>(
|
||||
notificationsKey,
|
||||
old => old?.filter(notification => notification?.id !== deletedId) ?? []
|
||||
);
|
||||
|
||||
return {previousNotifications};
|
||||
return { previousNotifications };
|
||||
},
|
||||
onError: (_err, _deletedId, context) => {
|
||||
if (context?.previousNotifications) {
|
||||
queryClient.setQueryData(["notifications", user?.uid], context.previousNotifications);
|
||||
queryClient.setQueryData(notificationsKey, context.previousNotifications);
|
||||
}
|
||||
},
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries(["notifications", user?.uid]);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: notificationsKey });
|
||||
}
|
||||
});
|
||||
};
|
@ -40,7 +40,7 @@ export const useGetEvents = () => {
|
||||
const newTimestamp = data.lastSyncTimestamp.seconds;
|
||||
if (newTimestamp > lastSyncTimestamp.current) {
|
||||
lastSyncTimestamp.current = newTimestamp;
|
||||
queryClient.invalidateQueries(["events", user?.uid, isFamilyView]);
|
||||
queryClient.invalidateQueries({queryKey: ["events", user?.uid, isFamilyView]});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export const useUpdateEvent = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("events")
|
||||
queryClients.invalidateQueries({queryKey: ["events"]})
|
||||
}
|
||||
})
|
||||
}
|
@ -54,7 +54,7 @@ export const useUpdateFeedback = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: (updatedFeedback) => {
|
||||
queryClient.invalidateQueries("feedbacks");
|
||||
queryClient.invalidateQueries({queryKey: ["feedbacks"]})
|
||||
|
||||
queryClient.setQueryData(
|
||||
["feedback", updatedFeedback.id],
|
||||
|
@ -18,7 +18,7 @@ export const useUpdateGrocery = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("groceries")
|
||||
queryClients.invalidateQueries({queryKey: ["groceries"]})
|
||||
}
|
||||
})
|
||||
}
|
@ -44,7 +44,7 @@ export const useUpdateHouseholdName = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("households"); // Invalidate the "households" query to refresh data
|
||||
queryClient.invalidateQueries({queryKey: ["households"]}); // Invalidate the "households" query to refresh data
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ export const useUpdateNote = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: (updatedNote) => {
|
||||
queryClient.invalidateQueries("braindumps");
|
||||
queryClient.invalidateQueries({queryKey: ["braindumps"]});
|
||||
|
||||
queryClient.setQueryData(
|
||||
["feedback", updatedNote.id],
|
||||
|
@ -165,7 +165,7 @@ export const useUpdateTodo = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClients.invalidateQueries("todos")
|
||||
queryClients.invalidateQueries({queryKey: ["todos"]})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export const useUpdateUserData = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("events");
|
||||
queryClient.invalidateQueries({queryKey: ["events"]})
|
||||
},
|
||||
});
|
||||
};
|
@ -302,7 +302,7 @@ export const useCalSync = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const handleNotification = async (notification: Notifications.Notification) => {
|
||||
queryClient.invalidateQueries(["events"]);
|
||||
queryClient.invalidateQueries({queryKey: ["events"]});
|
||||
};
|
||||
|
||||
const sub = Notifications.addNotificationReceivedListener(handleNotification);
|
||||
|
@ -31,7 +31,7 @@ export const useFetchAndSaveAppleEvents = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(["events"])
|
||||
queryClient.invalidateQueries({queryKey: ["events"]})
|
||||
},
|
||||
});
|
||||
};
|
@ -30,7 +30,7 @@ export const useFetchAndSaveGoogleEvents = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries(["events"]);
|
||||
queryClient.invalidateQueries({queryKey: ["events"]});
|
||||
console.log(`Successfully synced ${data.eventCount} events`);
|
||||
}
|
||||
});
|
||||
|
@ -130,7 +130,7 @@ export const useFetchAndSaveMicrosoftEvents = () => {
|
||||
}
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries(["events"]);
|
||||
queryClient.invalidateQueries({queryKey: ["events"]});
|
||||
console.log(`Successfully synced ${data.eventCount} Microsoft events`);
|
||||
},
|
||||
onError: (error) => {
|
||||
|
Reference in New Issue
Block a user