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:
nvrl committed 2026-09-05 09:10:04 +02:00
1 parent f42c0c6e4b
commit 54743346fe
6 files changed
+129 -13

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ export interface Entry {
id: number
title: string
body: string
excerpt: string
created_at: number
updated_at: number
shared: boolean