MCPcopy
hub / github.com/wavetermdev/waveterm / checkForUpdates

Method checkForUpdates

emain/updater.ts:151–176  ·  view source on GitHub ↗

* Checks if the configured interval time has passed since the last update check, and if so, checks for updates using the `autoUpdater` object * @param userInput Whether the user is requesting this. If so, an alert will report the result of the check.

(userInput: boolean)

Source from the content-addressed store, hash-verified

149 * @param userInput Whether the user is requesting this. If so, an alert will report the result of the check.
150 */
151 async checkForUpdates(userInput: boolean) {
152 const now = new Date();
153
154 // Run an update check always if the user requests it, otherwise only if there's an active update check interval and enough time has elapsed.
155 if (
156 userInput ||
157 (this.autoCheckInterval &&
158 (!this.lastUpdateCheck || Math.abs(now.getTime() - this.lastUpdateCheck.getTime()) > this.intervalms))
159 ) {
160 const result = await autoUpdater.checkForUpdates();
161
162 // If the user requested this check and we do not have an available update, let them know with a popup dialog. No need to tell them if there is an update, because we show a banner once the update is ready to install.
163 if (userInput && !result.downloadPromise) {
164 const dialogOpts: Electron.MessageBoxOptions = {
165 type: "info",
166 message: "There are currently no updates available.",
167 };
168 if (focusedWaveWindow) {
169 dialog.showMessageBox(focusedWaveWindow, dialogOpts);
170 }
171 }
172
173 // Only update the last check time if this is an automatic check. This ensures the interval remains consistent.
174 if (!userInput) this.lastUpdateCheck = now;
175 }
176 }
177
178 /**
179 * Prompts the user to install the downloaded application update and restarts the application

Callers 2

startMethod · 0.95
makeAppMenuItemsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected