(noteId: string)
| 249 | ); |
| 250 | } else { |
| 251 | // Empty doc (or guarding existing content from an empty regression): |
| 252 | // only refresh yjs_state on a row that already exists. Never create an |
| 253 | // empty "Untitled" row — that's the "don't persist blank notes" rule. |
| 254 | this.sql.exec( |
| 255 | "UPDATE notes SET yjs_state = ?, yjs_initialized_at = COALESCE(yjs_initialized_at, unixepoch()), updated_at = unixepoch() WHERE id = ?", |
| 256 | state, noteId |
| 257 | ); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | private scheduleDocPersist(noteId: string, doc: Y.Doc, delayMs: number, attempt = 0) { |
| 262 | const existing = this.saveTimers.get(noteId); |
| 263 | if (existing) clearTimeout(existing); |
no test coverage detected