[#475] fixed calendars selection persistence (#479)

This commit is contained in:
Camille Moussu
2026-01-26 11:14:42 +01:00
committed by GitHub
parent 7058f1c2d6
commit 1fc85e141e
5 changed files with 60 additions and 23 deletions
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
export function useSelectedCalendars(): string[] {
const [calendars, setCalendars] = useState<string[]>(() => {
if (typeof window === "undefined") return [];
try {
return JSON.parse(localStorage.getItem("selectedCalendars") ?? "[]");
} catch {
@@ -10,6 +11,8 @@ export function useSelectedCalendars(): string[] {
});
useEffect(() => {
if (typeof window === "undefined") return;
const onStorage = (e: StorageEvent) => {
if (e.key === "selectedCalendars") {
try {