(settings: SettingsType)
| 45 | lastUpdateCheck: Date; |
| 46 | |
| 47 | constructor(settings: SettingsType) { |
| 48 | this.intervalms = settings["autoupdate:intervalms"]; |
| 49 | console.log("Update check interval in milliseconds:", this.intervalms); |
| 50 | this.autoCheckEnabled = settings["autoupdate:enabled"]; |
| 51 | console.log("Update check enabled:", this.autoCheckEnabled); |
| 52 | |
| 53 | this._status = "up-to-date"; |
| 54 | this.lastUpdateCheck = new Date(0); |
| 55 | this.autoCheckInterval = null; |
| 56 | this.availableUpdateReleaseName = null; |
| 57 | |
| 58 | autoUpdater.autoInstallOnAppQuit = settings["autoupdate:installonquit"]; |
| 59 | console.log("Install update on quit:", settings["autoupdate:installonquit"]); |
| 60 | |
| 61 | // Only update the release channel if it's specified, otherwise use the one configured in the updater. |
| 62 | autoUpdater.channel = getUpdateChannel(settings); |
| 63 | autoUpdater.allowDowngrade = false; |
| 64 | |
| 65 | autoUpdater.removeAllListeners(); |
| 66 | |
| 67 | autoUpdater.on("error", (err) => { |
| 68 | console.log("updater error"); |
| 69 | console.log(err); |
| 70 | if (!err.toString()?.includes("net::ERR_INTERNET_DISCONNECTED")) this.status = "error"; |
| 71 | }); |
| 72 | |
| 73 | autoUpdater.on("checking-for-update", () => { |
| 74 | console.log("checking-for-update"); |
| 75 | this.status = "checking"; |
| 76 | }); |
| 77 | |
| 78 | autoUpdater.on("update-available", () => { |
| 79 | console.log("update-available; downloading..."); |
| 80 | this.status = "downloading"; |
| 81 | }); |
| 82 | |
| 83 | autoUpdater.on("update-not-available", () => { |
| 84 | console.log("update-not-available"); |
| 85 | this.status = "up-to-date"; |
| 86 | }); |
| 87 | |
| 88 | autoUpdater.on("update-downloaded", (event) => { |
| 89 | console.log("update-downloaded", [event]); |
| 90 | this.availableUpdateReleaseName = event.releaseName; |
| 91 | this.availableUpdateReleaseNotes = event.releaseNotes as string | null; |
| 92 | |
| 93 | // Display the update banner and create a system notification |
| 94 | this.status = "ready"; |
| 95 | const updateNotification = new Notification({ |
| 96 | title: "Wave Terminal", |
| 97 | body: "A new version of Wave Terminal is ready to install.", |
| 98 | }); |
| 99 | updateNotification.on("click", () => { |
| 100 | fireAndForget(this.promptToInstallUpdate.bind(this)); |
| 101 | }); |
| 102 | updateNotification.show(); |
| 103 | }); |
| 104 | } |
nothing calls this directly
no test coverage detected