mirror of
https://github.com/urosran/cally.git
synced 2026-10-27 08:04:13 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -11,11 +11,30 @@ export const useCreateEvent = () => {
|
||||
mutationKey: ["createEvent"],
|
||||
mutationFn: async (eventData: Partial<EventData>) => {
|
||||
try {
|
||||
if (eventData.id) {
|
||||
const snapshot = await firestore()
|
||||
.collection("Events")
|
||||
.where("id", "==", eventData.id)
|
||||
.get();
|
||||
|
||||
if (!snapshot.empty) {
|
||||
const docId = snapshot.docs[0].id;
|
||||
await firestore()
|
||||
.collection("Events")
|
||||
.doc(docId)
|
||||
.set({
|
||||
...eventData,
|
||||
creatorId: currentUser?.uid,
|
||||
familyId: profileData?.familyId
|
||||
}, {merge: true});
|
||||
return;
|
||||
}
|
||||
}
|
||||
await firestore()
|
||||
.collection("Events")
|
||||
.add({...eventData, creatorId: currentUser?.uid, familyId: profileData?.familyId})
|
||||
.add({...eventData, creatorId: currentUser?.uid, familyId: profileData?.familyId});
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -53,6 +53,13 @@ export const useGetEvents = () => {
|
||||
index === self.findIndex(e => e.id === event.id)
|
||||
);
|
||||
|
||||
allEvents = allEvents.filter(event => {
|
||||
if (event.private) {
|
||||
return event.creatorId === userId;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return await Promise.all(
|
||||
allEvents.map(async (event) => {
|
||||
const profileSnapshot = await db
|
||||
@@ -70,6 +77,7 @@ export const useGetEvents = () => {
|
||||
end: new Date(event.endDate.seconds * 1000),
|
||||
hideHours: event.allDay,
|
||||
eventColor: eventColor,
|
||||
notes: event.notes
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user