feat: condivisione e importazione automatica del codice comunità nelle playlist con priorità tonalità e autoscroll e rifinitura UI
This commit is contained in:
@@ -2,6 +2,7 @@ import { Component, inject, ApplicationRef } from '@angular/core';
|
||||
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
import { concat, interval, fromEvent } from 'rxjs';
|
||||
import { ToastController } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -12,6 +13,7 @@ import { concat, interval, fromEvent } from 'rxjs';
|
||||
export class AppComponent {
|
||||
private swUpdate = inject(SwUpdate);
|
||||
private appRef = inject(ApplicationRef);
|
||||
private toastCtrl = inject(ToastController);
|
||||
|
||||
constructor() {
|
||||
this.setupUpdates();
|
||||
@@ -55,14 +57,29 @@ export class AppComponent {
|
||||
}
|
||||
});
|
||||
|
||||
// 4. Activate update and reload when a new version is ready
|
||||
// 4. Activate update and reload when a new version is ready (Show interactive toast)
|
||||
this.swUpdate.versionUpdates
|
||||
.pipe(filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'))
|
||||
.subscribe(() => {
|
||||
console.log('[PWA-Update] New version ready! Activating and reloading...');
|
||||
this.swUpdate.activateUpdate().then(() => {
|
||||
window.location.reload();
|
||||
.subscribe(async () => {
|
||||
console.log('[PWA-Update] New version ready! Showing toast prompt...');
|
||||
const toast = await this.toastCtrl.create({
|
||||
message: 'Nuova versione dell\'applicazione disponibile!',
|
||||
position: 'bottom',
|
||||
color: 'secondary',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Aggiorna',
|
||||
role: 'cancel',
|
||||
handler: () => {
|
||||
console.log('[PWA-Update] Activating update and reloading...');
|
||||
this.swUpdate.activateUpdate().then(() => {
|
||||
window.location.replace(window.location.origin + window.location.pathname + '?update=' + Date.now());
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
await toast.present();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user