diff --git a/src/CmpModal.svelte b/src/CmpModal.svelte index b9d4bee..a7f7d08 100644 --- a/src/CmpModal.svelte +++ b/src/CmpModal.svelte @@ -41,7 +41,7 @@ async function createOrOpenNote(item: ResultNote): Promise { } function onInputEnter(event: CustomEvent): void { - console.log(event.detail) + // console.log(event.detail) openNote(event.detail) $modal.close() } diff --git a/src/stores.ts b/src/stores.ts index fb3f620..872a217 100644 --- a/src/stores.ts +++ b/src/stores.ts @@ -34,20 +34,20 @@ function createSelectedNote() { next: () => update(v => { const notes = get(resultNotes) - let id = notes.findIndex(n => n.path === v?.path) if (!notes.length) return null - if (id === -1) return notes[0] + let id = notes.findIndex(n => n.path === v?.path) + if (id === -1) return notes[0] ?? null id = id < notes.length - 1 ? id + 1 : 0 - return notes[id] + return notes[id] ?? null }), previous: () => update(v => { const notes = get(resultNotes) - let id = notes.findIndex(n => n.path === v?.path) if (!notes.length) return null - if (id === -1) return notes[0] + let id = notes.findIndex(n => n.path === v?.path) + if (id === -1) return notes[0] ?? null id = id > 0 ? id - 1 : notes.length - 1 - return notes[id] + return notes[id] ?? null }), } }