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 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-06 23:12:36 +01:00
co-authored by Claude Opus 4.6
parent d9c9663af2
commit d6f668b31d
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -7,6 +7,7 @@ import { extractTags } from '$lib/utils/tags.js';
export const notes = writable<Note[]>([]);
export const currentFilter = writable<NoteFilter>('all');
export const selectedTag = writable<string | null>(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 {
+2 -2
View File
@@ -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}
<div class="flex flex-col items-center justify-center py-20 text-[var(--text-muted)]">
<span class="mb-4 text-7xl">🥨</span>
<p class="font-['Press_Start_2P'] text-xs">