fix: updater not working (#3144)

(cherry picked from commit 0514da9759)
This commit is contained in:
Peng Xiao
2023-07-11 15:06:04 +08:00
committed by Alex Yang
parent 0c66780fda
commit 272835cfba
5 changed files with 39 additions and 45 deletions

View File

@@ -12,7 +12,7 @@
"scripts": {
"dev": "yarn cross-env DEV_SERVER_URL=http://localhost:8080 node scripts/dev.mjs",
"dev:prod": "yarn node scripts/dev.mjs",
"build": "zx scripts/build-layers.mjs",
"build": "NODE_ENV=production zx scripts/build-layers.mjs",
"generate-assets": "zx scripts/generate-assets.mjs",
"package": "electron-forge package",
"make": "electron-forge make",
@@ -59,7 +59,7 @@
"dependencies": {
"@toeverything/plugin-infra": "workspace:*",
"async-call-rpc": "^6.3.1",
"electron-updater": "^5.0.0",
"electron-updater": "^6.0.0",
"link-preview-js": "^3.0.4",
"lodash-es": "^4.17.21",
"nanoid": "^4.0.2",

View File

@@ -1,7 +1,7 @@
import { app, Menu } from 'electron';
import { revealLogFile } from '../logger';
import { checkForUpdatesAndNotify } from '../updater';
import { checkForUpdates } from '../updater';
import { isMacOS } from '../utils';
import { applicationMenuSubjects } from './subject';
@@ -125,7 +125,7 @@ export function createApplicationMenu() {
{
label: 'Check for Updates',
click: async () => {
await checkForUpdatesAndNotify(true);
await checkForUpdates(true);
},
},
],

View File

@@ -25,11 +25,11 @@ export const quitAndInstall = async () => {
};
let lastCheckTime = 0;
export const checkForUpdatesAndNotify = async (force = true) => {
export const checkForUpdates = async (force = true) => {
// check every 30 minutes (1800 seconds) at most
if (force || lastCheckTime + 1000 * 1800 < Date.now()) {
lastCheckTime = Date.now();
return await autoUpdater.checkForUpdatesAndNotify();
return await autoUpdater.checkForUpdates();
}
return void 0;
};
@@ -100,6 +100,6 @@ export const registerUpdater = async () => {
autoUpdater.forceDevUpdateConfig = isDev;
app.on('activate', async () => {
await checkForUpdatesAndNotify(false);
await checkForUpdates(false);
});
};

View File

@@ -1,7 +1,7 @@
import { app } from 'electron';
import type { NamespaceHandlers } from '../type';
import { checkForUpdatesAndNotify, quitAndInstall } from './electron-updater';
import { checkForUpdates, quitAndInstall } from './electron-updater';
export const updaterHandlers = {
currentVersion: async () => {
@@ -11,7 +11,7 @@ export const updaterHandlers = {
return quitAndInstall();
},
checkForUpdatesAndNotify: async () => {
const res = await checkForUpdatesAndNotify(true);
const res = await checkForUpdates(true);
if (res) {
const { updateInfo } = res;
return {