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 () => {
|
||||
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(() => {});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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<TitleEntry[]>([]);
|
||||
const loaded = ref(false);
|
||||
|
||||
async function load(): Promise<void> {
|
||||
if (loaded.value) return;
|
||||
async function refresh(): Promise<void> {
|
||||
items.value = await repo.notes.titles();
|
||||
loaded.value = true;
|
||||
}
|
||||
|
||||
async function reload(): Promise<void> {
|
||||
loaded.value = false;
|
||||
await load();
|
||||
}
|
||||
|
||||
return { items, loaded, load, reload };
|
||||
return { items, refresh };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user