refactor(trash): emptyTrash IPC dedup query (review T12 nit)

This commit is contained in:
altair823
2026-05-01 21:35:31 +09:00
parent dd74aec884
commit 3e4ad6ec91

View File

@@ -77,10 +77,12 @@ export function registerInboxApi(deps: InboxIpcDeps): void {
});
ipcMain.handle('inbox:emptyTrash', async () => {
const trashed = deps.repo.listTrashed({ limit: 1 });
// limit 200 한 번 — UI 표시 cap. count > 200 시 dialog message 만 부정확하지만
// emptyTrash() 내부 SQL 은 LIMIT 없으므로 실제 삭제는 모든 trash 노트 적용.
// v0.2.4 에서 repo.countTrashed() 추가 시 둘 다 정확해짐.
const trashed = deps.repo.listTrashed({ limit: 200 });
if (trashed.length === 0) return { confirmed: true, count: 0 };
// 정확한 카운트 위해 limit 200 으로 다시 조회
const fullCount = deps.repo.listTrashed({ limit: 200 }).length;
const fullCount = trashed.length;
const win = deps.getInboxWindow();
const opts: Electron.MessageBoxOptions = {
type: 'question',