← back to 4square Admin
4square admin: fall back to a populated source when the saved/default source is empty/invalid (old 'wallco:fliepaper-bugs' default had 0 rows → empty grid → publish/unpublish stuck disabled)
6ffa88ec8daa2df5262a9da69094b73fa97d73b6 · 2026-06-02 08:17:35 -0700 · SteveStudio2
Files touched
Diff
commit 6ffa88ec8daa2df5262a9da69094b73fa97d73b6
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue Jun 2 08:17:35 2026 -0700
4square admin: fall back to a populated source when the saved/default source is empty/invalid (old 'wallco:fliepaper-bugs' default had 0 rows → empty grid → publish/unpublish stuck disabled)
---
index.html | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/index.html b/index.html
index c92e6eb..b7d8739 100644
--- a/index.html
+++ b/index.html
@@ -339,6 +339,20 @@ async function loadSources() {
}
if (!j.ok) { toast('Sources error: ' + (j.error || 'unknown'), 'err'); return; }
SOURCES = j.sources;
+ // Resilience: never land on a non-existent / empty source. A stale localStorage
+ // pick or the old default 'wallco:fliepaper-bugs' (renamed away, 0 rows) would
+ // otherwise render an empty grid with publish/unpublish permanently disabled.
+ const validIds = new Set(
+ SOURCES.flatMap(g => (g.children || [])
+ .filter(c => c.id !== '__divider__' && (c.n == null || c.n > 0))
+ .map(c => c.id))
+ );
+ if (!validIds.has(CURRENT.id)) {
+ const fallback =
+ (SOURCES.find(g => g.id === 'wallco')?.children || []).find(c => c.id === 'wallco:all')?.id
+ || [...validIds][0];
+ if (fallback) { CURRENT.id = fallback; localStorage.setItem(LS.src, fallback); }
+ }
renderRail();
}
← f9ab3a8 add noreferrer to all target=_blank links
·
back to 4square Admin
·
4square admin: populate fliepaper-bugs matrix from fliepaper 4732fba →