board: spinner during first load instead of "no cards found"
An empty board on first load blurting "no cards found" was alarming on a board the user knew had cards. Track a cardsLoaded flag that flips on the first /api/cards (meta or full) response — or on a cached-cards hydration — and show a centred spinner placeholder while it's still false. The "no cards found" copy only shows once we've actually heard back and the set is genuinely empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d31e186bd9
commit
41272bd9ce
5 files changed
+27
-7
No files matched your search
+8
-2
@@ -45,6 +45,7 @@ window.openFindBar = openFindBar;
|
||||
window._reloadAll = async () => {
|
||||
await loadBuckets();
|
||||
state.cards = await api('api/cards') || [];
|
||||
state.cardsLoaded = true;
|
||||
renderBoard();
|
||||
refreshCalendar();
|
||||
// Let plugins / modules react to a full card reload (detail view checks
|
||||
@@ -86,10 +87,14 @@ function setCachedCards(cards) {
|
||||
}
|
||||
|
||||
async function loadCards() {
|
||||
// Phase 0: Show cached cards instantly (from previous session)
|
||||
// Phase 0: Show cached cards instantly (from previous session).
|
||||
// A hit here is enough to flip cardsLoaded — fresh meta will
|
||||
// overwrite state.cards a moment later, but the spinner→content
|
||||
// transition already happened.
|
||||
const cached = getCachedCards();
|
||||
if (cached.length) {
|
||||
state.cards = cached.map(c => ({ ...c, body: null }));
|
||||
state.cardsLoaded = true;
|
||||
updateSortUI();
|
||||
renderBoard();
|
||||
}
|
||||
@@ -97,6 +102,7 @@ async function loadCards() {
|
||||
// Phase 1: Load metadata → update board with fresh titles/tags/dates
|
||||
const meta = await api('api/cards/meta');
|
||||
if (!meta) return;
|
||||
state.cardsLoaded = true;
|
||||
state.cards = meta.map(c => ({ ...c, body: null }));
|
||||
setCachedCards(meta);
|
||||
updateSortUI();
|
||||
@@ -158,7 +164,7 @@ importFile?.addEventListener('change', async e => {
|
||||
if (!res.ok) throw new Error(text || `HTTP ${res.status}`);
|
||||
const data = JSON.parse(text);
|
||||
if (data.error) throw new Error(data.error);
|
||||
await loadBuckets(); state.cards = await api('api/cards'); renderBoard();
|
||||
await loadBuckets(); state.cards = await api('api/cards'); state.cardsLoaded = true; renderBoard();
|
||||
} catch (err) {
|
||||
await showDialog({ title: 'import failed', message: err.message || 'Unknown error', danger: true, okLabel: 'OK', cancelLabel: '' });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user