mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-04 00:47:01 +01:00
feat: autosave drafts, and stop losing them on a switch
Only Ctrl-S and :w ever wrote. A closed laptop, a crashed tab or an expired session took the draft with it, and clicking another entry in the list silently discarded unsaved work without so much as a prompt. Every change now goes to localStorage immediately and to the server two and a half seconds after typing stops. Opening an entry that has a stash newer than the server's copy restores it and says so, the way vim reports a swap file; :e! and :q! discard it. Switching entries flushes the outgoing draft first. The save response carries the entry's excerpt, so a save patches its list row in place instead of re-reading the whole list — which autosave would otherwise have done every few seconds.
This commit is contained in:
1 parent
f42c0c6e4b
commit
54743346fe
6 files changed
+129
-13
No files matched your search
@@ -107,7 +107,10 @@ export const commands: CommandSpec[] = [
|
||||
const open = diary.open
|
||||
diary.editing = false
|
||||
diary.dirty = false
|
||||
if (open) await diary.guard(() => diary.openEntry(open.id))
|
||||
if (open) {
|
||||
diary.dropStash(open.id)
|
||||
await diary.guard(() => diary.openEntry(open.id))
|
||||
}
|
||||
hooks.focusList()
|
||||
},
|
||||
},
|
||||
@@ -168,6 +171,7 @@ export const commands: CommandSpec[] = [
|
||||
const open = requireOpen()
|
||||
if (!open) return
|
||||
diary.dirty = false
|
||||
diary.dropStash(open.id)
|
||||
await diary.guard(() => diary.openEntry(open.id, diary.editing))
|
||||
diary.say(`entry:${open.id} reloaded`)
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user