From 58d51e9672fb562bb10ebb1956e0a174eacd0639 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Thu, 26 Mar 2026 08:29:06 +0000 Subject: [PATCH 1/2] [#555] Persist language filter in localStorage Save selected language to localStorage on filter change and restore it on revisit when no lang param is in the URL. Defaults to "all" when no saved preference exists. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/FilterBar.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/FilterBar.tsx b/src/components/FilterBar.tsx index 0c6a3c14..44d55350 100644 --- a/src/components/FilterBar.tsx +++ b/src/components/FilterBar.tsx @@ -53,12 +53,24 @@ export function FilterBar({ writer, genre, lang, tab }: FilterBarProps) { return () => document.removeEventListener("mousedown", handleClick); }, []); + // Restore saved language preference on first visit (no lang param in URL) + useEffect(() => { + if (lang !== "all") return; + try { + const saved = localStorage.getItem("plotlink_lang"); + if (saved && saved !== "all" && (LANGUAGES as readonly string[]).includes(saved)) { + router.replace(buildHref({ tab, writer, genre, lang: saved })); + } + } catch {} + }, []); // eslint-disable-line react-hooks/exhaustive-deps + function toggle(key: FilterKey) { setOpen(open === key ? null : key); } function navigate(params: { tab: string; writer: string; genre: string; lang: string }) { setOpen(null); + try { localStorage.setItem("plotlink_lang", params.lang); } catch {} router.push(buildHref(params)); } From c915cff3aa8a2221f05dd4f7c4bded2f633b6706 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Thu, 26 Mar 2026 08:32:39 +0000 Subject: [PATCH 2/2] [#275] Check URL param presence instead of normalized value Use window.location.search to detect whether lang was explicitly provided in the URL. Only restore localStorage preference when the param is truly absent, not when explicitly set to "all". Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/FilterBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/FilterBar.tsx b/src/components/FilterBar.tsx index 44d55350..14f425b1 100644 --- a/src/components/FilterBar.tsx +++ b/src/components/FilterBar.tsx @@ -55,7 +55,8 @@ export function FilterBar({ writer, genre, lang, tab }: FilterBarProps) { // Restore saved language preference on first visit (no lang param in URL) useEffect(() => { - if (lang !== "all") return; + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has("lang")) return; // explicit param — don't override try { const saved = localStorage.getItem("plotlink_lang"); if (saved && saved !== "all" && (LANGUAGES as readonly string[]).includes(saved)) {