mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
Faimly
This commit is contained in:
@ -49,7 +49,7 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
(event: CalendarEvent) => {
|
||||
if (mode === "day" || mode === "week") {
|
||||
setEditVisible(true);
|
||||
console.log({event});
|
||||
// console.log({event});
|
||||
setEventForEdit(event);
|
||||
} else {
|
||||
setMode("day");
|
||||
@ -88,7 +88,7 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
[profileData]
|
||||
);
|
||||
|
||||
console.log({memoizedWeekStartsOn, profileData: profileData?.firstDayOfWeek})
|
||||
// console.log({memoizedWeekStartsOn, profileData: profileData?.firstDayOfWeek})
|
||||
|
||||
const isSameDate = useCallback((date1: Date, date2: Date) => {
|
||||
return (
|
||||
@ -155,7 +155,7 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
}, {} as Record<string, CalendarEvent[]>);
|
||||
|
||||
const endTime = Date.now();
|
||||
console.log("memoizedEvents computation time:", endTime - startTime, "ms");
|
||||
// console.log("memoizedEvents computation time:", endTime - startTime, "ms");
|
||||
|
||||
return {enrichedEvents, filteredEvents};
|
||||
}, [events, selectedDate, mode]);
|
||||
|
||||
@ -4,6 +4,7 @@ import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { isFamilyViewAtom } from "@/components/pages/calendar/atoms";
|
||||
import { colorMap } from "@/constants/colorMap";
|
||||
import {uuidv4} from "@firebase/util";
|
||||
|
||||
export const useGetEvents = () => {
|
||||
const { user, profileData } = useAuthContext();
|
||||
@ -20,23 +21,22 @@ export const useGetEvents = () => {
|
||||
|
||||
// If family view is active, include family, creator, and attendee events
|
||||
if (isFamilyView) {
|
||||
|
||||
const familyQuery = db.collection("Events").where("familyID", "==", familyId);
|
||||
const creatorQuery = db.collection("Events").where("creatorId", "==", userId);
|
||||
const familyQuery = db.collection("Events").where("familyId", "==", familyId);
|
||||
const attendeeQuery = db.collection("Events").where("attendees", "array-contains", userId);
|
||||
|
||||
const [familySnapshot, creatorSnapshot, attendeeSnapshot] = await Promise.all([
|
||||
const [familySnapshot, attendeeSnapshot] = await Promise.all([
|
||||
familyQuery.get(),
|
||||
creatorQuery.get(),
|
||||
attendeeQuery.get(),
|
||||
]);
|
||||
|
||||
// Collect all events
|
||||
const familyEvents = familySnapshot.docs.map(doc => doc.data());
|
||||
const creatorEvents = creatorSnapshot.docs.map(doc => doc.data());
|
||||
const attendeeEvents = attendeeSnapshot.docs.map(doc => doc.data());
|
||||
|
||||
allEvents = [...familyEvents, ...creatorEvents, ...attendeeEvents];
|
||||
// console.log("Family events not in creator query: ", familyEvents.filter(event => !creatorEvents.some(creatorEvent => creatorEvent.id === event.id)));
|
||||
|
||||
|
||||
allEvents = [...familyEvents, ...attendeeEvents];
|
||||
} else {
|
||||
// Only include creator and attendee events when family view is off
|
||||
const creatorQuery = db.collection("Events").where("creatorId", "==", userId);
|
||||
@ -59,7 +59,7 @@ export const useGetEvents = () => {
|
||||
if (event.id) {
|
||||
uniqueEventsMap.set(event.id, event); // Ensure uniqueness for events with IDs
|
||||
} else {
|
||||
uniqueEventsMap.set(Math.random().toString(36), event); // Generate a temp key for events without ID
|
||||
uniqueEventsMap.set(uuidv4(), event); // Generate a temp key for events without ID
|
||||
}
|
||||
});
|
||||
const uniqueEvents = Array.from(uniqueEventsMap.values());
|
||||
|
||||
Reference in New Issue
Block a user