- cloud-sync-handlers 수동 ok/fail -> ipcSuccess/ipcError 헬퍼 (6 핸들러)
- catch {} -> catch(error) 에러 메시지 보강 32건 (11 ipc handler 파일)
KEEP: template-handlers(주석 명시 에러 무시), license-handlers(이미 헬퍼 사용),
audio-handlers stop().catch(() => {})(의도적 무시)
정책: docs/REFACTOR_POLICY.md DP2
77 lines
2.8 KiB
TypeScript
77 lines
2.8 KiB
TypeScript
// src/main/ipc/memo-handlers.ts
|
|
// Phase 10.3: 음성 메모 태그 IPC 핸들러
|
|
|
|
import { ipcMain } from 'electron'
|
|
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
|
import { ipcSuccess, ipcError, ErrorCode, D3ROError } from '@d3ro/core/errors'
|
|
import { getMemoService } from '../services/MemoService'
|
|
import type {
|
|
GetTagsParams,
|
|
AddTagParams,
|
|
RemoveTagParams,
|
|
SearchByTagParams,
|
|
ExportMemoParams
|
|
} from '@d3ro/core/types'
|
|
|
|
export function registerMemoHandlers(): void {
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.GET_TAGS, async (_event, params: GetTagsParams) => {
|
|
try {
|
|
return ipcSuccess(getMemoService().getTagsForEntry(params.historyId))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBQueryFailed, `Failed to get tags for history entry: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.ADD_TAG, async (_event, params: AddTagParams) => {
|
|
try {
|
|
return ipcSuccess(getMemoService().addTag(params.historyId, params.tag))
|
|
} catch (err) {
|
|
if (err instanceof D3ROError && err.code === ErrorCode.MemoTagDuplicate) {
|
|
return ipcError(ErrorCode.MemoTagDuplicate, err.message)
|
|
}
|
|
return ipcError(ErrorCode.DBWriteFailed, 'Failed to add tag')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.REMOVE_TAG, async (_event, params: RemoveTagParams) => {
|
|
try {
|
|
getMemoService().removeTag(params.historyId, params.tag)
|
|
return ipcSuccess(undefined)
|
|
} catch (err) {
|
|
if (err instanceof D3ROError && err.code === ErrorCode.MemoTagNotFound) {
|
|
return ipcError(ErrorCode.MemoTagNotFound, err.message)
|
|
}
|
|
return ipcError(ErrorCode.DBWriteFailed, 'Failed to remove tag')
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.GET_ALL_TAGS, async () => {
|
|
try {
|
|
return ipcSuccess(getMemoService().getAllTags())
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBQueryFailed, `Failed to get all tags: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.SEARCH_BY_TAG, async (_event, params: SearchByTagParams) => {
|
|
try {
|
|
return ipcSuccess(getMemoService().searchByTag(params))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBQueryFailed, `Failed to search by tag: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.MEMO.EXPORT, async (_event, params: ExportMemoParams) => {
|
|
try {
|
|
return ipcSuccess(getMemoService().exportMarkdown(params))
|
|
} catch (err) {
|
|
if (err instanceof D3ROError && err.code === ErrorCode.MemoExportFailed) {
|
|
return ipcError(ErrorCode.MemoExportFailed, err.message)
|
|
}
|
|
return ipcError(ErrorCode.MemoExportFailed, 'Failed to export memo')
|
|
}
|
|
})
|
|
}
|