Added update detection
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
"index": "/index.html",
|
"index": "/index.html",
|
||||||
|
"navigationRequestStrategy": "freshness",
|
||||||
"assetGroups": [
|
"assetGroups": [
|
||||||
{
|
{
|
||||||
"name": "app",
|
"name": "app",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "WorkTime",
|
"name": "WorkTime",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"author": "Ionic Framework",
|
"author": "Ionic Framework",
|
||||||
"homepage": "https://ionicframework.com/",
|
"homepage": "https://ionicframework.com/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
|
import {AlertController, IonApp, IonRouterOutlet} from '@ionic/angular/standalone';
|
||||||
|
import {SwUpdate} from "@angular/service-worker";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -9,5 +10,36 @@ import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
|
|||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
public static currentDate: any;
|
public static currentDate: any;
|
||||||
constructor() {}
|
constructor(private updates: SwUpdate, private alerts: AlertController) {
|
||||||
|
if (updates.isEnabled) {
|
||||||
|
updates.checkForUpdate().then(async available => {
|
||||||
|
if (available) await this.showUpdateAlert();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async showUpdateAlert() {
|
||||||
|
const alert = await this.alerts.create({
|
||||||
|
header: "Update verfügbar!",
|
||||||
|
message: 'Möchtest du das Update herunterladen?',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: "Nein",
|
||||||
|
role: "cancel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Ja",
|
||||||
|
role: "destructive"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
await alert.present();
|
||||||
|
const result = await alert.onDidDismiss();
|
||||||
|
|
||||||
|
if (result.role == "destructive") {
|
||||||
|
await this.updates.activateUpdate();
|
||||||
|
document.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user