refactor: reduce CalDAV sync to login and manual sync button only
- Remove auto-login sync in AuthGuard - Remove 10s interval sync and syncAndReload in calendar tab - Remove lazy syncOnce pattern in ChatService AI callbacks - Remove CaldavService dependency from ChatService constructor
This commit is contained in:
@@ -17,7 +17,6 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { useThemeStore } from "../../stores/ThemeStore";
|
||||
import BaseBackground from "../../components/BaseBackground";
|
||||
import { EventService } from "../../services";
|
||||
import { CaldavConfigService } from "../../services/CaldavConfigService";
|
||||
import { useEventsStore } from "../../stores";
|
||||
import { useDropdownPosition } from "../../hooks/useDropdownPosition";
|
||||
|
||||
@@ -108,25 +107,11 @@ const Calendar = () => {
|
||||
}
|
||||
}, [monthIndex, currentYear, setEvents]);
|
||||
|
||||
// Sync CalDAV in background, then reload events
|
||||
const syncAndReload = useCallback(async () => {
|
||||
try {
|
||||
await CaldavConfigService.sync();
|
||||
await loadEvents();
|
||||
} catch {
|
||||
// Sync failed — not critical
|
||||
}
|
||||
}, [loadEvents]);
|
||||
|
||||
// Load events instantly on focus, then sync in background periodically
|
||||
// Load events from DB on focus
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
loadEvents();
|
||||
syncAndReload();
|
||||
|
||||
const interval = setInterval(syncAndReload, 10_000);
|
||||
return () => clearInterval(interval);
|
||||
}, [loadEvents, syncAndReload]),
|
||||
}, [loadEvents]),
|
||||
);
|
||||
|
||||
// Re-open overlay after back navigation from editEvent
|
||||
|
||||
Reference in New Issue
Block a user