Skip to content

Commit

Permalink
chore: better is update available check
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 2, 2025
1 parent 3532bc8 commit e63fc9e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
32 changes: 32 additions & 0 deletions .yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/out/AppUpdater.js b/out/AppUpdater.js
index 48e23fbfbe5ee25aadd98eaa3d7fa035588f4002..93d2b7726dcceff64e92f1831056813aeaec6b4b 100644
--- a/out/AppUpdater.js
+++ b/out/AppUpdater.js
@@ -361,6 +361,7 @@ class AppUpdater extends events_1.EventEmitter {
this._logger.info(`Update for version ${this.currentVersion.format()} is not available (latest version: ${updateInfo.version}, downgrade is ${this.allowDowngrade ? "allowed" : "disallowed"}).`);
this.emit("update-not-available", updateInfo);
return {
+ isUpdateAvailable: false,
versionInfo: updateInfo,
updateInfo,
};
@@ -370,6 +371,7 @@ class AppUpdater extends events_1.EventEmitter {
const cancellationToken = new builder_util_runtime_1.CancellationToken();
//noinspection ES6MissingAwait
return {
+ isUpdateAvailable: true,
versionInfo: updateInfo,
updateInfo,
cancellationToken,
diff --git a/out/main.d.ts b/out/main.d.ts
index 28c3de7dbe0ccf70d0a1d87be50ea7a7ddd3d210..5c6dce42f4a27f71bb0c722dd547eb72fbb9d0af 100644
--- a/out/main.d.ts
+++ b/out/main.d.ts
@@ -20,6 +20,7 @@ export interface ResolvedUpdateFileInfo {
packageInfo?: PackageFileInfo;
}
export interface UpdateCheckResult {
+ readonly isUpdateAvailable: boolean
readonly updateInfo: UpdateInfo;
readonly downloadPromise?: Promise<Array<string>> | null;
readonly cancellationToken?: CancellationToken;
2 changes: 1 addition & 1 deletion satellite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"conf": "^13.1.0",
"debounce-fn": "^6.0.0",
"electron-store": "^10.0.1",
"electron-updater": "^6.4.1",
"electron-updater": "patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch",
"exit-hook": "^4.0.0",
"infinitton-idisplay": "^1.2.0",
"koa": "^2.15.3",
Expand Down
9 changes: 4 additions & 5 deletions satellite/src/electronUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ export class ElectronUpdater {
autoUpdater
.checkForUpdates()
.then((info) => {
// HACK: If there is a cancellation token, it found an update.
// This is not a good test, but the only other ways require comparing version numbers the same as electron-updater, or to listen to the emitted events instead
const hasUpdate = !!info?.cancellationToken
if (!info) return

if (notifyWithDialog) {
if (hasUpdate) {
if (info.isUpdateAvailable) {
dialog
.showMessageBox({
title: 'Companion Satellite',
Expand Down Expand Up @@ -96,7 +95,7 @@ export class ElectronUpdater {
}
} else {
// Show a system notification instead
if (hasUpdate) {
if (info.isUpdateAvailable) {
if (!this.#updateNotification) {
this.#updateNotification = new Notification({
title: 'An update is available',
Expand Down
20 changes: 18 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4734,7 +4734,7 @@ __metadata:
languageName: node
linkType: hard

"electron-updater@npm:^6.4.1":
"electron-updater@npm:6.4.1":
version: 6.4.1
resolution: "electron-updater@npm:6.4.1"
dependencies:
Expand All @@ -4750,6 +4750,22 @@ __metadata:
languageName: node
linkType: hard

"electron-updater@patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch":
version: 6.4.1
resolution: "electron-updater@patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch::version=6.4.1&hash=5e29a4"
dependencies:
builder-util-runtime: "npm:9.3.1"
fs-extra: "npm:^10.1.0"
js-yaml: "npm:^4.1.0"
lazy-val: "npm:^1.0.5"
lodash.escaperegexp: "npm:^4.1.2"
lodash.isequal: "npm:^4.5.0"
semver: "npm:^7.6.3"
tiny-typed-emitter: "npm:^2.1.0"
checksum: 10c0/713a8323ca314ff76e03eb912dd02290c19646896cc24357d1dde9cd573297b8de21cd96e591425acae7a93ec2094b61e92952896d3a9dc7f1c901a760e295b5
languageName: node
linkType: hard

"electron@npm:34.0.2":
version: 34.0.2
resolution: "electron@npm:34.0.2"
Expand Down Expand Up @@ -9171,7 +9187,7 @@ __metadata:
electron: "npm:34.0.2"
electron-builder: "npm:^26.0.1"
electron-store: "npm:^10.0.1"
electron-updater: "npm:^6.4.1"
electron-updater: "patch:electron-updater@npm%3A6.4.1#~/.yarn/patches/electron-updater-npm-6.4.1-ef33e6cc39.patch"
exit-hook: "npm:^4.0.0"
infinitton-idisplay: "npm:^1.2.0"
koa: "npm:^2.15.3"
Expand Down

0 comments on commit e63fc9e

Please sign in to comment.