From f704eebc7e49d2feb6aeb8e6a54f701e970cfd18 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 27 Nov 2025 15:06:26 +0100 Subject: [PATCH] feat(ipc): improve error handling and streamline IPC initialization --- electron/ipc-handler.ts | 14 ++++++++------ electron/ipc-handlers/exec.ts | 2 +- electron/ipc-handlers/index.ts | 6 ++++++ src/app/core/startup/startup.service.ts | 5 ++++- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 electron/ipc-handlers/index.ts diff --git a/electron/ipc-handler.ts b/electron/ipc-handler.ts index 5d0fe4433..603c42207 100644 --- a/electron/ipc-handler.ts +++ b/electron/ipc-handler.ts @@ -1,11 +1,13 @@ import { log } from 'electron-log/main'; import { pluginNodeExecutor } from './plugin-node-executor'; -import { initAppDataIpc } from './ipc-handlers/app-data'; -import { initAppControlIpc } from './ipc-handlers/app-control'; -import { initSystemIpc } from './ipc-handlers/system'; -import { initJiraIpc } from './ipc-handlers/jira'; -import { initGlobalShortcutsIpc } from './ipc-handlers/global-shortcuts'; -import { initExecIpc } from './ipc-handlers/exec'; +import { + initAppControlIpc, + initAppDataIpc, + initExecIpc, + initGlobalShortcutsIpc, + initJiraIpc, + initSystemIpc, +} from './ipc-handlers'; export const initIpcInterfaces = (): void => { // Initialize plugin node executor (registers IPC handlers) diff --git a/electron/ipc-handlers/exec.ts b/electron/ipc-handlers/exec.ts index 30e23d0ba..6864462fc 100644 --- a/electron/ipc-handlers/exec.ts +++ b/electron/ipc-handlers/exec.ts @@ -21,7 +21,7 @@ const execWithFrontendErrorHandlerInform = async ( const allowedCommands: string[] = (existingData[COMMAND_MAP_PROP] as string[]) || []; if (!Array.isArray(allowedCommands)) { - throw new Error('allowedCommands is no array ???'); + throw new Error('Invalid configuration: allowedCommands must be an array'); } if (allowedCommands.includes(command)) { exec(command, (err) => { diff --git a/electron/ipc-handlers/index.ts b/electron/ipc-handlers/index.ts new file mode 100644 index 000000000..b23c88b4c --- /dev/null +++ b/electron/ipc-handlers/index.ts @@ -0,0 +1,6 @@ +export { initAppControlIpc } from './app-control'; +export { initAppDataIpc } from './app-data'; +export { initExecIpc } from './exec'; +export { initGlobalShortcutsIpc } from './global-shortcuts'; +export { initJiraIpc } from './jira'; +export { initSystemIpc } from './system'; diff --git a/src/app/core/startup/startup.service.ts b/src/app/core/startup/startup.service.ts index d69fbf4d2..470e418ee 100644 --- a/src/app/core/startup/startup.service.ts +++ b/src/app/core/startup/startup.service.ts @@ -37,6 +37,9 @@ import { SyncSafetyBackupService } from '../../imex/sync/sync-safety-backup.serv const w = window as Window & { productivityTips?: string[][]; randomIndex?: number }; +/** Delay before running deferred initialization tasks (plugins, storage checks, etc.) */ +const DEFERRED_INIT_DELAY_MS = 1000; + @Injectable({ providedIn: 'root', }) @@ -114,7 +117,7 @@ export class StartupService { this._handleAppStartRating(); await this._initPlugins(); - }, 1000); + }, DEFERRED_INIT_DELAY_MS); if (IS_ELECTRON) { window.ea.informAboutAppReady();