fix: persist normalized fishing plans

This commit is contained in:
ik
2026-09-21 18:47:08 +07:00
parent 0b830a9978
commit 4972b11fb0
3 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -29,7 +29,13 @@ import Layout from "../layouts/Layout.astro";
}).slice(0, 5);
};
const readPlan = (): Array<Record<string, string>> => {
try { return normalisePlan(JSON.parse(localStorage.getItem(planStorageKey) || "[]")); }
try {
const raw = localStorage.getItem(planStorageKey) || "[]";
const normalised = normalisePlan(JSON.parse(raw));
const serialised = JSON.stringify(normalised);
if (serialised !== raw) localStorage.setItem(planStorageKey, serialised);
return normalised;
}
catch { return []; }
};
const shared = new URLSearchParams(location.search).get("plan");