release 1.1.3
This commit is contained in:
+60
-18
@@ -2,13 +2,17 @@ import { Component, inject } from '@angular/core';
|
||||
import {
|
||||
AlertController,
|
||||
IonApp,
|
||||
IonRouterOutlet
|
||||
IonRouterOutlet,
|
||||
LoadingController
|
||||
} from '@ionic/angular/standalone';
|
||||
import { check } from '@tauri-apps/plugin-updater';
|
||||
import { check, DownloadEvent } from '@tauri-apps/plugin-updater';
|
||||
import { isTauri } from '@tauri-apps/api/core';
|
||||
import { platform } from '@tauri-apps/plugin-os';
|
||||
import { relaunch } from '@tauri-apps/plugin-process';
|
||||
import { TranslationService } from './i18n/translation.service';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: 'app.component.html',
|
||||
@@ -16,6 +20,7 @@ import { TranslationService } from './i18n/translation.service';
|
||||
})
|
||||
export class AppComponent {
|
||||
readonly alertController: AlertController = inject(AlertController);
|
||||
readonly loadingController: LoadingController = inject(LoadingController);
|
||||
readonly translationService: TranslationService = inject(TranslationService);
|
||||
|
||||
constructor() {
|
||||
@@ -27,6 +32,11 @@ export class AppComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
// Snap handles updates on Linux.
|
||||
if (platform() === 'linux') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const update = await check();
|
||||
|
||||
@@ -40,29 +50,61 @@ export class AppComponent {
|
||||
{
|
||||
text: 'OK',
|
||||
handler: async () => {
|
||||
const loading = await this.loadingController.create({
|
||||
message:
|
||||
this.translationService.translate('updateDownloading'),
|
||||
spinner: 'crescent',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
await loading.present();
|
||||
|
||||
let downloaded = 0;
|
||||
let total = 0;
|
||||
|
||||
try {
|
||||
// Show loading message
|
||||
alert.message =
|
||||
this.translationService.translate('updateDownloading');
|
||||
await update.downloadAndInstall((event: DownloadEvent) => {
|
||||
switch (event.event) {
|
||||
case 'Started':
|
||||
total = event.data.contentLength ?? 0;
|
||||
downloaded = 0;
|
||||
break;
|
||||
|
||||
// Disable the button while updating
|
||||
const okButton = alert.buttons[0];
|
||||
if (typeof okButton !== 'string') {
|
||||
okButton.htmlAttributes = { disabled: true };
|
||||
}
|
||||
case 'Progress':
|
||||
downloaded += event.data.chunkLength;
|
||||
|
||||
await update.downloadAndInstall();
|
||||
if (total > 0) {
|
||||
const percent = Math.min(
|
||||
100,
|
||||
Math.round((downloaded / total) * 100)
|
||||
);
|
||||
|
||||
loading.message = `${this.translationService.translate('updateDownloading')} ${percent}%`;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'Finished':
|
||||
loading.message =
|
||||
this.translationService.translate('updateInstalling');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
await loading.dismiss();
|
||||
await relaunch();
|
||||
} catch (error) {
|
||||
console.error('Failed to install update:', error);
|
||||
alert.message =
|
||||
this.translationService.translate('updateFailed');
|
||||
|
||||
const okButton = alert.buttons[0];
|
||||
// Re-enable the button if the update failed
|
||||
if (typeof okButton !== 'string') {
|
||||
okButton.htmlAttributes = { disabled: false };
|
||||
}
|
||||
await loading.dismiss();
|
||||
|
||||
const errorAlert = await this.alertController.create({
|
||||
header: this.translationService.translate('updateFailed'),
|
||||
message: String(error),
|
||||
buttons: ['OK']
|
||||
});
|
||||
|
||||
await errorAlert.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,13 @@ export const translations = {
|
||||
sendUmpiresMessage: '{umpire} - {serviceJudge}',
|
||||
version: 'Version',
|
||||
updateAvailable: 'Update available',
|
||||
newVersion: 'A new version {version} is available. The application will restart to install the update.',
|
||||
newVersion:
|
||||
'A new version {version} is available. The application will restart to install the update.',
|
||||
english: 'English',
|
||||
hungarian: 'Hungarian',
|
||||
updateDownloading: 'Downloading and installing update...',
|
||||
updateFailed: 'Failed to install the update. Please try again.',
|
||||
updateDownloading: 'Downloading update...',
|
||||
updateInstalling: 'Installing update...',
|
||||
updateFailed: 'Failed to install the update. Please try again.'
|
||||
},
|
||||
|
||||
hu: {
|
||||
@@ -87,11 +89,13 @@ export const translations = {
|
||||
sendUmpiresMessage: '{umpire} - {serviceJudge}',
|
||||
version: 'Verzió',
|
||||
updateAvailable: 'Új verzió elérhető',
|
||||
newVersion: 'Új elérhető verzió: {version}. A frissítések telepítése után az alkalmazás újraindul.',
|
||||
newVersion:
|
||||
'Új elérhető verzió: {version}. A frissítések telepítése után az alkalmazás újraindul.',
|
||||
english: 'Angol',
|
||||
hungarian: 'Magyar',
|
||||
updateDownloading: 'Frissítés letöltése és telepítése...',
|
||||
updateDownloading: 'Frissítés letöltése...',
|
||||
updateFailed: 'Frissítés sikertelen. Kérlek próbáld újra.',
|
||||
updateInstalling: 'Frissítés telepítése...'
|
||||
}
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<ion-col sizeLg="6" pushLg="3">
|
||||
<ion-item>
|
||||
<ion-label class="ion-text-center"
|
||||
>{{ 'version' | translate }}: 1.1.2</ion-label
|
||||
>{{ 'version' | translate }}: 1.1.3</ion-label
|
||||
>
|
||||
</ion-item>
|
||||
</ion-col>
|
||||
|
||||
Reference in New Issue
Block a user