Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions desktop/src/main/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export async function initAutoUpdater(
currentChannel = loadChannel()
const { autoUpdater } = await import("electron-updater")

if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") {
console.warn("Auto-updater not available (app is not code-signed)")
return
}

autoUpdater.autoDownload = true
autoUpdater.autoInstallOnAppQuit = true
autoUpdater.allowPrerelease = currentChannel === "beta"
Expand Down Expand Up @@ -137,6 +142,13 @@ export async function initAutoUpdater(

export async function checkForUpdates(): Promise<void> {
const { autoUpdater } = await import("electron-updater")
if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") {
sendUpdateStatus({
state: "error",
error: "Auto-update is not available (app is not code-signed)",
})
return
}
await autoUpdater.checkForUpdates()
}

Expand All @@ -146,12 +158,22 @@ export async function checkForUpdatesWithChannel(
const { autoUpdater } = await import("electron-updater")
currentChannel = channel
saveChannel(channel)
if (!autoUpdater || typeof autoUpdater.checkForUpdates !== "function") {
sendUpdateStatus({
state: "error",
error: "Auto-update is not available (app is not code-signed)",
})
return
}
autoUpdater.allowPrerelease = channel === "beta"
autoUpdater.channel = channel === "beta" ? "beta" : "latest"
await autoUpdater.checkForUpdates()
}

export async function installUpdate(): Promise<void> {
const { autoUpdater } = await import("electron-updater")
if (!autoUpdater || typeof autoUpdater.quitAndInstall !== "function") {
return
}
autoUpdater.quitAndInstall()
}
Loading