diff --git a/package.json b/package.json index 8d3c3dc..666a8e0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "genshin-locker", "private": true, "productName": "genshin-locker", - "version": "1.1.0", + "version": "1.1.1", "description": "Genshin artifact scraper and manager", "main": "packages/main/dist/index.cjs", "scripts": { diff --git a/packages/ipc-api/src/api.ts b/packages/ipc-api/src/api.ts index d357741..28a9aa8 100644 --- a/packages/ipc-api/src/api.ts +++ b/packages/ipc-api/src/api.ts @@ -29,6 +29,9 @@ export const mainApi: MainAPI = { if (!this.webContents) { throw Error(`Message ${channel} was made before webContents was set.`) } + if (this.webContents.isDestroyed()) { + throw Error(`Message ${channel} was made on destroyed webContents.`) + } return this.webContents.send(channel, ...args) }, handle(channel, listener) { diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 12dfa49..a9a44ba 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -3,6 +3,8 @@ import { app } from 'electron' import { platform } from 'node:process' import { exit } from 'process' +import { autoUpdater } from 'electron-updater' + import { restoreOrCreateWindow } from './mainWindow' import { setSecurityRestrictions } from './security-restrictions' @@ -62,14 +64,5 @@ app * Like `npm run compile` does. It's ok 😅 */ if (import.meta.env.PROD) { - app - .whenReady() - .then(() => import('electron-updater')) - .then((module) => { - const autoUpdater = - module.autoUpdater || - (module.default.autoUpdater as (typeof module)['autoUpdater']) - return autoUpdater.checkForUpdatesAndNotify() - }) - .catch((e) => console.error('Failed check and install updates:', e)) + app.whenReady().then(() => autoUpdater.checkForUpdatesAndNotify()) }