canti primo tag

This commit is contained in:
David Frassi
2026-05-16 17:24:59 +02:00
commit 0c33fc6fcf
106 changed files with 28210 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { Component, inject, ApplicationRef } from '@angular/core';
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker';
import { filter, first } from 'rxjs/operators';
import { concat, interval } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
standalone: false,
})
export class AppComponent {
private swUpdate = inject(SwUpdate);
private appRef = inject(ApplicationRef);
constructor() {
this.setupUpdates();
}
private setupUpdates() {
if (this.swUpdate.isEnabled) {
// Controlla aggiornamenti ogni 5 minuti invece di 30
const everyFiveMinutes$ = interval(5 * 60 * 1000);
everyFiveMinutes$.subscribe(() => {
console.log('Checking for PWA updates...');
this.swUpdate.checkForUpdate();
});
this.swUpdate.versionUpdates
.pipe(filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'))
.subscribe(() => {
if (confirm('Una nuova versione dell\'app è disponibile. Vuoi aggiornare ora?')) {
this.swUpdate.activateUpdate().then(() => {
window.location.reload();
});
}
});
}
}
}