One Calendar is a privacy-first calendar web app built with Next.js. It has modern security features, including e2ee, password-protected sharing, and self-destructing share links ๐Ÿ“… calendar.xyehr.cn
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #190 from EvanTechDev/feature/fix-calendar-view-switching-bug

fix(calendar): apply persisted default view only once to avoid overriding manual switches

authored by

Evan Huang and committed by
GitHub
54331a96 79abe386

+10 -3
+10 -3
components/app/calendar.tsx
··· 92 92 | "analytics" 93 93 | "settings"; 94 94 95 + const isCalendarView = ( 96 + view: string, 97 + ): view is "day" | "week" | "four-day" | "month" | "year" => { 98 + return ["day", "week", "four-day", "month", "year"].includes(view); 99 + }; 100 + 95 101 export interface CalendarEvent { 96 102 id: string; 97 103 title: string; ··· 183 189 const [toastPosition, setToastPosition] = useLocalStorage< 184 190 "bottom-left" | "bottom-center" | "bottom-right" 185 191 >("toast-position", "bottom-right"); 192 + const hasAppliedDefaultView = useRef(false); 186 193 187 194 useEffect(() => { 188 - if (view !== defaultView) { 189 - setView(defaultView as ViewType); 190 - } 195 + if (hasAppliedDefaultView.current) return; 196 + setView(isCalendarView(defaultView) ? defaultView : "week"); 197 + hasAppliedDefaultView.current = true; 191 198 }, [defaultView]); 192 199 193 200 useEffect(() => {