From c33e81257b2edd06ce837d1d8a012bfe3856d129 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Fri, 6 Mar 2026 22:31:28 +0100 Subject: [PATCH] fix: prevent "No crumbs yet" flash on page refresh Add notesLoaded store flag set after IDB read completes. Gate the empty state message behind it so it only shows once we know the store is empty. Co-Authored-By: Claude Opus 4.6 --- src/lib/stores/notes.ts | 4 +++- src/routes/+page.svelte | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/stores/notes.ts b/src/lib/stores/notes.ts index 763022f..ce13241 100644 --- a/src/lib/stores/notes.ts +++ b/src/lib/stores/notes.ts @@ -7,6 +7,7 @@ import { extractTags } from '$lib/utils/tags.js'; export const notes = writable([]); export const currentFilter = writable('all'); export const selectedTag = writable(null); +export const notesLoaded = writable(false); export const filteredNotes = derived( [notes, selectedTag, currentFilter], @@ -49,8 +50,9 @@ export async function loadNotes(filter: NoteFilter = 'all') { const cached = await getAllNotes(); if (cached.length > 0) { notes.set(cached); - currentFilter.set(filter); } + currentFilter.set(filter); + notesLoaded.set(true); // Then fetch from server in the background try { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b61a6bf..89fe20e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,7 +2,7 @@ import NoteGrid from '$lib/components/NoteGrid.svelte'; import NoteEditor from '$lib/components/NoteEditor.svelte'; import TagFilter from '$lib/components/TagFilter.svelte'; - import { pinnedNotes, unpinnedNotes, selectedTag, currentFilter, notes } from '$lib/stores/notes.js'; + import { pinnedNotes, unpinnedNotes, selectedTag, currentFilter, notes, notesLoaded } from '$lib/stores/notes.js'; import { onMount } from 'svelte'; import { get } from 'svelte/store'; import type { Note } from '$lib/types/index.js'; @@ -73,7 +73,7 @@ onEdit={openEditor} /> -{#if $pinnedNotes.length === 0 && $unpinnedNotes.length === 0} +{#if $notesLoaded && $pinnedNotes.length === 0 && $unpinnedNotes.length === 0}
🥨