aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/index.ts')
-rw-r--r--packages/main/src/index.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts
index bcdc3d7..a886a16 100644
--- a/packages/main/src/index.ts
+++ b/packages/main/src/index.ts
@@ -19,22 +19,24 @@
19 * SPDX-License-Identifier: AGPL-3.0-only 19 * SPDX-License-Identifier: AGPL-3.0-only
20 */ 20 */
21 21
22import { readFileSync } from 'node:fs';
23import { readFile } from 'node:fs/promises';
22import { arch } from 'node:os'; 24import { arch } from 'node:os';
23import path from 'node:path'; 25import path from 'node:path';
24import { URL } from 'node:url'; 26import { URL } from 'node:url';
25 27
26import { 28import {
27 ServiceToMainIpcMessage, 29 ServiceToMainIpcMessage,
28 unreadCount, 30 UnreadCount,
29 WebSource, 31 WebSource,
30} from '@sophie/service-shared'; 32} from '@sophie/service-shared';
31import { 33import {
32 action, 34 Action,
33 MainToRendererIpcMessage, 35 MainToRendererIpcMessage,
34 RendererToMainIpcMessage, 36 RendererToMainIpcMessage,
35} from '@sophie/shared'; 37} from '@sophie/shared';
36import { app, BrowserView, BrowserWindow, ipcMain } from 'electron'; 38import { app, BrowserView, BrowserWindow, ipcMain } from 'electron';
37import { ensureDirSync, readFile, readFileSync } from 'fs-extra'; 39import { ensureDirSync } from 'fs-extra';
38import { autorun } from 'mobx'; 40import { autorun } from 'mobx';
39import { getSnapshot, onAction, onPatch } from 'mobx-state-tree'; 41import { getSnapshot, onAction, onPatch } from 'mobx-state-tree';
40import osName from 'os-name'; 42import osName from 'os-name';
@@ -45,7 +47,7 @@ import {
45 installDevToolsExtensions, 47 installDevToolsExtensions,
46 openDevToolsWhenReady, 48 openDevToolsWhenReady,
47} from './devTools'; 49} from './devTools';
48import init from './init'; 50import initReactions from './initReactions';
49import { createMainStore } from './stores/MainStore'; 51import { createMainStore } from './stores/MainStore';
50import { getLogger } from './utils/log'; 52import { getLogger } from './utils/log';
51 53
@@ -128,7 +130,7 @@ let mainWindow: BrowserWindow | undefined;
128 130
129const store = createMainStore(); 131const store = createMainStore();
130 132
131init(store) 133initReactions(store)
132 // eslint-disable-next-line promise/always-return -- `then` instead of top-level await. 134 // eslint-disable-next-line promise/always-return -- `then` instead of top-level await.
133 .then((disposeCompositionRoot) => { 135 .then((disposeCompositionRoot) => {
134 app.on('will-quit', disposeCompositionRoot); 136 app.on('will-quit', disposeCompositionRoot);
@@ -267,7 +269,7 @@ async function createWindow(): Promise<unknown> {
267 return; 269 return;
268 } 270 }
269 try { 271 try {
270 const actionToDispatch = action.parse(rawAction); 272 const actionToDispatch = Action.parse(rawAction);
271 switch (actionToDispatch.action) { 273 switch (actionToDispatch.action) {
272 case 'set-selected-service-id': 274 case 'set-selected-service-id':
273 store.shared.setSelectedServiceId(actionToDispatch.serviceId); 275 store.shared.setSelectedServiceId(actionToDispatch.serviceId);
@@ -331,7 +333,7 @@ async function createWindow(): Promise<unknown> {
331 // otherwise electron emits a no handler registered warning. 333 // otherwise electron emits a no handler registered warning.
332 break; 334 break;
333 case ServiceToMainIpcMessage.SetUnreadCount: 335 case ServiceToMainIpcMessage.SetUnreadCount:
334 log.log('Unread count:', unreadCount.parse(args[0])); 336 log.log('Unread count:', UnreadCount.parse(args[0]));
335 break; 337 break;
336 default: 338 default:
337 log.error('Unknown IPC message:', channel, args); 339 log.error('Unknown IPC message:', channel, args);