mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 16:34:54 +00:00
added calendar events refresh
This commit is contained in:
@ -2,12 +2,13 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Calendar } from "react-native-big-calendar";
|
||||
import { ActivityIndicator, ScrollView, StyleSheet, View, ViewStyle } from "react-native";
|
||||
import { useGetEvents } from "@/hooks/firebase/useGetEvents";
|
||||
import { useAtom, useSetAtom } from "jotai";
|
||||
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
||||
import {
|
||||
editVisibleAtom,
|
||||
eventForEditAtom,
|
||||
isAllDayAtom,
|
||||
modeAtom,
|
||||
refreshTriggerAtom,
|
||||
selectedDateAtom,
|
||||
selectedNewEventDateAtom,
|
||||
} from "@/components/pages/calendar/atoms";
|
||||
@ -31,7 +32,7 @@ const getTotalMinutes = () => {
|
||||
|
||||
export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
({ calendarHeight }) => {
|
||||
const { data: events, isLoading } = useGetEvents();
|
||||
const { data: events, isLoading, refetch } = useGetEvents();
|
||||
const { profileData } = useAuthContext();
|
||||
const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom);
|
||||
const [mode, setMode] = useAtom(modeAtom);
|
||||
@ -39,6 +40,7 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
const setEditVisible = useSetAtom(editVisibleAtom);
|
||||
const [isAllDay, setIsAllDay] = useAtom(isAllDayAtom);
|
||||
const setEventForEdit = useSetAtom(eventForEditAtom);
|
||||
const shouldRefresh = useAtomValue(refreshTriggerAtom);
|
||||
const setSelectedNewEndDate = useSetAtom(selectedNewEventDateAtom);
|
||||
|
||||
const {isSyncing} = useSyncEvents()
|
||||
@ -233,6 +235,17 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
setOffsetMinutes(getTotalMinutes());
|
||||
}, [events, mode]);
|
||||
|
||||
useEffect(() => {
|
||||
refetch()
|
||||
.then(() => {
|
||||
console.log('✅ Events refreshed successfully');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('❌ Events refresh failed:', error);
|
||||
});
|
||||
}, [shouldRefresh, refetch])
|
||||
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<View style={styles.loadingContainer}>
|
||||
|
||||
Reference in New Issue
Block a user