feat(v0210): inbox:{update-raw-text,list-revisions,restore-revision} IPC

This commit is contained in:
altair823
2026-05-09 20:44:52 +09:00
parent 7541d3c9e4
commit b4c2d85b26
2 changed files with 122 additions and 0 deletions

View File

@@ -269,6 +269,29 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
await deps.health.runOnce();
return { ok: true };
});
// v0.2.10 Cut C — raw_text 가변 + revision 보존.
// updateRawText: 빈 문자열 reject (trim 후 length===0). 그 외엔 그대로 (newline/space 보존).
// listRevisions: 그대로 반환 (camelCase 이미 hydrate 됨).
// restoreRevision: repo throw → { ok: false } (UI 가 에러 표시).
ipcMain.handle('inbox:update-raw-text', async (_e, id: string, newText: string) => {
if (typeof newText !== 'string' || newText.trim().length === 0) {
return { ok: false as const, reason: 'empty' as const };
}
deps.repo.updateRawText(id, newText);
return { ok: true as const };
});
ipcMain.handle('inbox:list-revisions', (_e, id: string) => deps.repo.listRevisions(id));
ipcMain.handle('inbox:restore-revision', async (_e, id: string, revId: number) => {
try {
deps.repo.restoreRevision(id, revId);
return { ok: true as const };
} catch (e) {
return { ok: false as const, reason: (e as Error).message };
}
});
}
export function pushNoteUpdated(getWin: () => BrowserWindow | null, note: Note): void {