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}
🥨