fix: clarify empty fishing plan shares
This commit is contained in:
@@ -31,7 +31,13 @@ import Layout from "../layouts/Layout.astro";
|
||||
catch { return []; }
|
||||
};
|
||||
const shared = new URLSearchParams(location.search).get("plan");
|
||||
if (shared) { try { const imported = normalisePlan(JSON.parse(shared)); if (imported.length) localStorage.setItem(planStorageKey, JSON.stringify(imported)); } catch { if (shareStatus) shareStatus.textContent = "Ссылка плана не распознана"; } }
|
||||
if (shared) {
|
||||
try {
|
||||
const imported = normalisePlan(JSON.parse(shared));
|
||||
if (imported.length) localStorage.setItem(planStorageKey, JSON.stringify(imported));
|
||||
else if (shareStatus) shareStatus.textContent = "В ссылке нет сохранённых точек";
|
||||
} catch { if (shareStatus) shareStatus.textContent = "Ссылка плана не распознана"; }
|
||||
}
|
||||
const render = () => {
|
||||
if (!list || !empty) return;
|
||||
const plan = readPlan();
|
||||
@@ -52,7 +58,9 @@ import Layout from "../layouts/Layout.astro";
|
||||
});
|
||||
};
|
||||
document.querySelector<HTMLButtonElement>("[data-plan-share]")?.addEventListener("click", async () => {
|
||||
const url = new URL(location.href); url.search = ""; url.searchParams.set("plan", JSON.stringify(readPlan()));
|
||||
const plan = readPlan();
|
||||
if (!plan.length) { if (shareStatus) shareStatus.textContent = "Сначала добавьте точку в план"; return; }
|
||||
const url = new URL(location.href); url.search = ""; url.searchParams.set("plan", JSON.stringify(plan));
|
||||
try {
|
||||
if (navigator.share) await navigator.share({ title: "Мой план рыбалки RF4", url: url.toString() });
|
||||
else await navigator.clipboard.writeText(url.toString());
|
||||
|
||||
Reference in New Issue
Block a user