Skip to content

Commit 6a767e0

Browse files
committed
add required update system
1 parent b1ae781 commit 6a767e0

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

packages/i18n/en/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const en: BaseTranslation = {
55
updater: {
66
title: 'New version available {version: string}',
77
message: 'A new version ({version: string}) of Lindo is available. Do you want to update?',
8-
download: 'Download on github',
8+
messageRequired: 'A required update ({version: string}) of Lindo is available, you must download it on GitHub.',
9+
download: 'Download on GitHub',
910
ignore: 'Ignore'
1011
},
1112
gameMenu: {

packages/i18n/fr/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const fr: Translation = {
55
updater: {
66
title: 'Nouvelle version disponible {version}',
77
message: 'Une nouvelle version ({version}) de Lindo est disponible. Voulez-vous télécharger la mis à jour?',
8+
messageRequired:
9+
'Une nouvelle version ({version}) obligatoire de Lindo est disponible, vous pouvez la télécharger sur GitHub.',
810
download: 'Télécharger sur github',
911
ignore: 'Ignorer'
1012
},

packages/i18n/i18n-types.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ type RootTranslation = {
2727
*/
2828
message: RequiredParams<'version'>
2929
/**
30-
* Download on github
30+
* A required update ({version}) of Lindo is available, you must download it on GitHub.
31+
* @param {string} version
32+
*/
33+
messageRequired: RequiredParams<'version'>
34+
/**
35+
* Download on GitHub
3136
*/
3237
download: string
3338
/**
@@ -1084,7 +1089,11 @@ export type TranslationFunctions = {
10841089
*/
10851090
message: (arg: { version: string }) => LocalizedString
10861091
/**
1087-
* Download on github
1092+
* A required update ({version}) of Lindo is available, you must download it on GitHub.
1093+
*/
1094+
messageRequired: (arg: { version: string }) => LocalizedString
1095+
/**
1096+
* Download on GitHub
10881097
*/
10891098
download: () => LocalizedString
10901099
/**

packages/main/updater/app-updater.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,28 @@ export class AppUpdater {
3131
repo: 'lindo'
3232
})
3333
.then((res) => {
34+
console.log(res)
3435
const latestVersion = res.data.tag_name.replaceAll('v', '')
36+
const required = res.data.body?.includes('__update:required__') ?? false
3537
logger.info({ latestVersion, currentVersion })
3638
if (compareVersions(latestVersion, currentVersion) === 1) {
37-
this._showUpdateDialog(latestVersion)
39+
this._showUpdateDialog(latestVersion, required)
3840
}
3941
})
4042
}
4143

42-
private _showUpdateDialog(newVersion: string) {
43-
const buttons: Array<string> = [this._i18n.LL.main.updater.download(), this._i18n.LL.main.updater.ignore()]
44+
private _showUpdateDialog(newVersion: string, required: boolean) {
45+
const buttons: Array<string> = [this._i18n.LL.main.updater.download()]
46+
if (!required) {
47+
buttons.push(this._i18n.LL.main.updater.ignore())
48+
}
4449
return dialog
4550
.showMessageBox({
4651
type: 'info',
4752
title: this._i18n.LL.main.updater.title({ version: newVersion }),
48-
message: this._i18n.LL.main.updater.message({ version: newVersion }),
53+
message: required
54+
? this._i18n.LL.main.updater.messageRequired({ version: newVersion })
55+
: this._i18n.LL.main.updater.message({ version: newVersion }),
4956
buttons
5057
})
5158
.then((returnValue) => {

0 commit comments

Comments
 (0)