[#446] removed direct state update (#468)

This commit is contained in:
Camille Moussu
2026-01-21 15:17:49 +01:00
committed by GitHub
parent 23d50f250d
commit 00742119be
38 changed files with 119 additions and 1366 deletions
+14
View File
@@ -10,6 +10,7 @@ import { syncCalendarRegistrations } from "./operations";
export function WebSocketGate() {
const socketRef = useRef<WebSocketWithCleanup | null>(null);
const previousCalendarListRef = useRef<string[]>([]);
const previousTempCalendarListRef = useRef<string[]>([]);
const dispatch = useAppDispatch();
const isAuthenticated = useAppSelector((state) =>
Boolean(state.user.userData && state.user.tokens)
@@ -18,6 +19,10 @@ export function WebSocketGate() {
const [isSocketOpen, setIsSocketOpen] = useState(false);
const calendarList = useSelectedCalendars();
const tempCalendarList = Object.keys(
useAppSelector((state) => state?.calendars?.templist) ?? {}
);
const onMessage = useCallback(
(message: unknown) => {
updateCalendars(message, dispatch);
@@ -76,5 +81,14 @@ export function WebSocketGate() {
);
}, [isSocketOpen, calendarList]);
useEffect(() => {
syncCalendarRegistrations(
isSocketOpen,
socketRef,
tempCalendarList,
previousTempCalendarListRef
);
}, [isSocketOpen, tempCalendarList]);
return null;
}