fix: auto-merge new apps from roadmap.json into localStorage on load
This commit is contained in:
parent
6944c83c0b
commit
e228b2bbde
19
index.html
19
index.html
|
|
@ -851,7 +851,24 @@ let appSearch = '';
|
||||||
async function loadData(forceFile = false) {
|
async function loadData(forceFile = false) {
|
||||||
if (!forceFile) {
|
if (!forceFile) {
|
||||||
const raw = localStorage.getItem(STORAGE_KEY);
|
const raw = localStorage.getItem(STORAGE_KEY);
|
||||||
if (raw) { try { data = JSON.parse(raw); return; } catch (_) {} }
|
if (raw) {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(raw);
|
||||||
|
// Merge any new apps added to roadmap.json that aren't in localStorage yet
|
||||||
|
const res = await fetch('/roadmap.json');
|
||||||
|
const fresh = await res.json();
|
||||||
|
const existingIds = new Set(data.apps.map(a => a.id));
|
||||||
|
let changed = false;
|
||||||
|
for (const app of fresh.apps) {
|
||||||
|
if (!existingIds.has(app.id)) {
|
||||||
|
data.apps.push(app);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) persist();
|
||||||
|
return;
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const res = await fetch('/roadmap.json');
|
const res = await fetch('/roadmap.json');
|
||||||
data = await res.json();
|
data = await res.json();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue