diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-01-27 00:17:22 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-02-08 21:43:17 +0100 |
commit | 9546dc2aa39ab096ccc723786e718a739d0bdaf9 (patch) | |
tree | 9c3afc6155cc59f6dd1235397230aaa15a5f8cec /packages/main/src/index.ts | |
parent | refactor: Apply shared store patches in batches (diff) | |
download | sophie-9546dc2aa39ab096ccc723786e718a739d0bdaf9.tar.gz sophie-9546dc2aa39ab096ccc723786e718a739d0bdaf9.tar.zst sophie-9546dc2aa39ab096ccc723786e718a739d0bdaf9.zip |
refactor: Coding conventions
Make sure that files have a default import with the same name as the
file whenever possible to reduce surprise.
Also shuffles around some file names for better legibility.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/index.ts')
-rw-r--r-- | packages/main/src/index.ts | 16 |
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 | ||
22 | import { readFileSync } from 'node:fs'; | ||
23 | import { readFile } from 'node:fs/promises'; | ||
22 | import { arch } from 'node:os'; | 24 | import { arch } from 'node:os'; |
23 | import path from 'node:path'; | 25 | import path from 'node:path'; |
24 | import { URL } from 'node:url'; | 26 | import { URL } from 'node:url'; |
25 | 27 | ||
26 | import { | 28 | import { |
27 | ServiceToMainIpcMessage, | 29 | ServiceToMainIpcMessage, |
28 | unreadCount, | 30 | UnreadCount, |
29 | WebSource, | 31 | WebSource, |
30 | } from '@sophie/service-shared'; | 32 | } from '@sophie/service-shared'; |
31 | import { | 33 | import { |
32 | action, | 34 | Action, |
33 | MainToRendererIpcMessage, | 35 | MainToRendererIpcMessage, |
34 | RendererToMainIpcMessage, | 36 | RendererToMainIpcMessage, |
35 | } from '@sophie/shared'; | 37 | } from '@sophie/shared'; |
36 | import { app, BrowserView, BrowserWindow, ipcMain } from 'electron'; | 38 | import { app, BrowserView, BrowserWindow, ipcMain } from 'electron'; |
37 | import { ensureDirSync, readFile, readFileSync } from 'fs-extra'; | 39 | import { ensureDirSync } from 'fs-extra'; |
38 | import { autorun } from 'mobx'; | 40 | import { autorun } from 'mobx'; |
39 | import { getSnapshot, onAction, onPatch } from 'mobx-state-tree'; | 41 | import { getSnapshot, onAction, onPatch } from 'mobx-state-tree'; |
40 | import osName from 'os-name'; | 42 | import osName from 'os-name'; |
@@ -45,7 +47,7 @@ import { | |||
45 | installDevToolsExtensions, | 47 | installDevToolsExtensions, |
46 | openDevToolsWhenReady, | 48 | openDevToolsWhenReady, |
47 | } from './devTools'; | 49 | } from './devTools'; |
48 | import init from './init'; | 50 | import initReactions from './initReactions'; |
49 | import { createMainStore } from './stores/MainStore'; | 51 | import { createMainStore } from './stores/MainStore'; |
50 | import { getLogger } from './utils/log'; | 52 | import { getLogger } from './utils/log'; |
51 | 53 | ||
@@ -128,7 +130,7 @@ let mainWindow: BrowserWindow | undefined; | |||
128 | 130 | ||
129 | const store = createMainStore(); | 131 | const store = createMainStore(); |
130 | 132 | ||
131 | init(store) | 133 | initReactions(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); |