diff --git a/frontend/src/components/CommandPalette.vue b/frontend/src/components/CommandPalette.vue index 5eddbdf..7f43885 100644 --- a/frontend/src/components/CommandPalette.vue +++ b/frontend/src/components/CommandPalette.vue @@ -87,9 +87,12 @@ function onKeydown(e: KeyboardEvent) { } onMounted(async () => { - await titles.load(); + // Focus first: typing a command must not wait on the note list. await nextTick(); input.value?.focus(); + // A failed refresh keeps the last list rather than breaking the palette; the + // commands work either way. + titles.refresh().catch(() => {}); }); diff --git a/frontend/src/stores/titles.ts b/frontend/src/stores/titles.ts index 46c2b2b..32ae243 100644 --- a/frontend/src/stores/titles.ts +++ b/frontend/src/stores/titles.ts @@ -13,20 +13,17 @@ export interface TitleEntry { // because the command palette lists it so someone can jump straight to a note by // name. That is recall, which is what this app is for; `resolve()` went with the // links. +// +// Fetched again every time the palette opens. It used to load once per session +// behind a `loaded` flag, with nothing ever clearing it, so a note written after +// the first open could not be found by name until a page reload (#5165). The last +// list stays in place meanwhile, so the palette never opens empty. export const useTitlesStore = defineStore("titles", () => { const items = ref([]); - const loaded = ref(false); - async function load(): Promise { - if (loaded.value) return; + async function refresh(): Promise { items.value = await repo.notes.titles(); - loaded.value = true; } - async function reload(): Promise { - loaded.value = false; - await load(); - } - - return { items, loaded, load, reload }; + return { items, refresh }; });