Skip to content

Commit 2b84229

Browse files
authored
[Feat] (Auto-)Updater improvements (#4830)
* Support auto-updates of the AppImage version * Still show the update message if the auto-updater isn't supported Ideally we'd show a packaging format-specific message here, but this is still better than no message at all
1 parent 33d60d1 commit 2b84229

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

public/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"info": {
108108
"update": {
109109
"detail": "Do you want to download the update in the background?",
110+
"detailNoAutoupdate": "Automatic updates are not supported for your packaging format. Please use your package manager to update.",
110111
"message": "There is a new Version available!",
111112
"message-finished": "Do you want to restart Heroic now?",
112113
"title": "Heroic Games Launcher",

src/backend/constants/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ export const isFlatpak = Boolean(env.FLATPAK_ID)
1818
export const isSnap = Boolean(env.SNAP)
1919
export const isAppImage = Boolean(env.APPIMAGE)
2020
export const flatpakRuntimeVersion = env.FLATPAK_RUNTIME_VERSION
21+
export const autoUpdateSupported = isWindows || isMac || isAppImage

src/backend/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async function initializeWindow(): Promise<BrowserWindow> {
257257
} else {
258258
Menu.setApplicationMenu(null)
259259
mainWindow.loadFile(join(publicDir, 'index.html'))
260-
if (globalConf.checkForUpdatesOnStartup && !isLinux) {
260+
if (globalConf.checkForUpdatesOnStartup) {
261261
autoUpdater.checkForUpdates()
262262
}
263263
}

src/backend/updater.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,46 @@ import { t } from 'i18next'
55
import { showDialogBoxModalAuto } from './dialog/dialog'
66
import { logError, LogPrefix } from './logger'
77
import { windowIcon } from './constants/paths'
8-
import { isLinux } from './constants/environment'
8+
import { autoUpdateSupported } from './constants/environment'
99

1010
autoUpdater.autoDownload = false
1111
autoUpdater.autoInstallOnAppQuit = false
1212

1313
async function showAutoupdateDialog() {
14-
if (isLinux) {
15-
return
16-
}
14+
let messageDetail
15+
let buttons
1716

18-
const { response } = await dialog.showMessageBox({
19-
title: t('box.info.update.title', 'Heroic Games Launcher'),
20-
message: t('box.info.update.message', 'There is a new Version available!'),
21-
detail: t(
17+
if (autoUpdateSupported) {
18+
messageDetail = t(
2219
'box.info.update.detail',
2320
'Do you want to download the update in the background?'
24-
),
25-
26-
icon: nativeImage.createFromPath(windowIcon),
27-
buttons: [
21+
)
22+
buttons = [
2823
t('box.update', 'Update'),
2924
t('box.postpone', 'Postpone'),
3025
t('box.changelog', 'Changelog')
3126
]
27+
} else {
28+
messageDetail = t(
29+
'box.info.update.detailNoAutoupdate',
30+
'Automatic updates are not supported for your packaging format. Please use your package manager to update.'
31+
)
32+
buttons = [t('box.ok'), t('box.changelog', 'Changelog')]
33+
}
34+
35+
let { response } = await dialog.showMessageBox({
36+
title: t('box.info.update.title', 'Heroic Games Launcher'),
37+
message: t('box.info.update.message', 'There is a new Version available!'),
38+
detail: messageDetail,
39+
40+
icon: nativeImage.createFromPath(windowIcon),
41+
buttons
3242
})
43+
44+
// "Ok" button becomes "Postpone" (to just close the dialog), "Changelog" gets
45+
// the correct index (1 -> 2)
46+
if (!autoUpdateSupported) response++
47+
3348
if (response === 0) {
3449
autoUpdater.downloadUpdate()
3550
}

0 commit comments

Comments
 (0)