AGPL-3.0-only, a source link in the app, and everything on dev since #5 #6
@@ -87,9 +87,12 @@ function onKeydown(e: KeyboardEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await titles.load();
|
// Focus first: typing a command must not wait on the note list.
|
||||||
await nextTick();
|
await nextTick();
|
||||||
input.value?.focus();
|
input.value?.focus();
|
||||||
|
// A failed refresh keeps the last list rather than breaking the palette; the
|
||||||
|
// commands work either way.
|
||||||
|
titles.refresh().catch(() => {});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,17 @@ export interface TitleEntry {
|
|||||||
// because the command palette lists it so someone can jump straight to a note by
|
// 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
|
// name. That is recall, which is what this app is for; `resolve()` went with the
|
||||||
// links.
|
// 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", () => {
|
export const useTitlesStore = defineStore("titles", () => {
|
||||||
const items = ref<TitleEntry[]>([]);
|
const items = ref<TitleEntry[]>([]);
|
||||||
const loaded = ref(false);
|
|
||||||
|
|
||||||
async function load(): Promise<void> {
|
async function refresh(): Promise<void> {
|
||||||
if (loaded.value) return;
|
|
||||||
items.value = await repo.notes.titles();
|
items.value = await repo.notes.titles();
|
||||||
loaded.value = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reload(): Promise<void> {
|
return { items, refresh };
|
||||||
loaded.value = false;
|
|
||||||
await load();
|
|
||||||
}
|
|
||||||
|
|
||||||
return { items, loaded, load, reload };
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user