import { ipcMain } from 'electron' import { IPC } from '../../../shared/ipc-channels' import { BookRegistryService } from '../../services/book-registry' import { CockpitService } from '../../services/cockpit.service' import type { GlobalSettingsService } from '../../services/global-settings' import { wrap } from '../result' export function registerCockpitHandlers( registry: BookRegistryService, settings: GlobalSettingsService ): void { ipcMain.handle( IPC.COCKPIT_SUMMARY, (_e, { bookId, volumeId }: { bookId: string; volumeId?: string }) => wrap(() => new CockpitService(registry.getDb(bookId), settings).getSummary(volumeId)) ) ipcMain.handle(IPC.COCKPIT_MARK_SEEN, (_e, { bookId }: { bookId: string }) => wrap(() => { new CockpitService(registry.getDb(bookId), settings).markSeen() }) ) ipcMain.handle(IPC.COCKPIT_SHOULD_SHOW, (_e, { bookId }: { bookId: string }) => wrap(() => new CockpitService(registry.getDb(bookId), settings).shouldShowOnOpen()) ) }