Skip to content
Snippets Groups Projects
Commit c6eda35c authored by AUBRY JEAN-PASCAL's avatar AUBRY JEAN-PASCAL Committed by David Dorchies
Browse files

Resolve "PWA: L'application ne se met pas à jour sur Firefox et Safari"

parent e5268678
No related branches found
No related tags found
2 merge requests!252release: version 4.18.0,!237Resolve "PWA: L'application ne se met pas à jour sur Firefox et Safari"
......@@ -19,12 +19,12 @@
"/*.css",
"/*.js",
"/*.json",
"/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2|eot)",
"/3rdpartylicenses.txt",
"/MaterialIcons-Regular.1e50f5c2ffa6aba4.eot",
"/assets/**",
"!/**/*.pdf",
"!/**/*.php",
"/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
"!/assets/docs/javascripts/matomo-tracking.js"
]
}
}
......
......@@ -5,7 +5,7 @@ import { NotificationsService } from "./notifications.service";
import { UserConfirmationService } from "./user-confirmation.service";
import { interval } from "rxjs";
@Injectable()
@Injectable({providedIn: 'root'})
export class ServiceWorkerUpdateService {
constructor(
private swUpdate: SwUpdate,
......@@ -28,11 +28,12 @@ export class ServiceWorkerUpdateService {
}
this.swUpdate.versionUpdates.subscribe(evt => {
console.log("ServiceWorkerUpdateService event:", evt.type);
switch (evt.type) {
case 'VERSION_DETECTED':
let ver = (evt as any).version?.appData?.version ?? "<NA>";
console.log("ServiceWorkerUpdateService: VERSION_DETECTED", ver);
notificationService.notify(i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_DETECTED", { "ver": ver }), 10000);
this.notificationService.notify(this.i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_DETECTED", { "ver": ver }), 10000);
break;
case 'VERSION_READY':
......@@ -40,15 +41,15 @@ export class ServiceWorkerUpdateService {
const newVer = (evt as any).latestVersion?.appData?.version ?? "<NA>";
console.log("ServiceWorkerUpdateService: VERSION_READY", currVer, "->", newVer);
notificationService.notify(i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer }), 10000);
this.notificationService.notify(this.i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer }), 10000);
// PLANTE si on stocke le message dans une variable !!!!
// const msg = i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer });
// notificationService.notify(msg, 10000);
// -> ReferenceError: can't access lexical declaration 'xxx' before initialization
// avec xxx qui varie d'une fois à l'autre !!!
userConfirmationService.askUserConfirmation("Confirmation",
i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer })).then(data => {
this.userConfirmationService.askUserConfirmation("Confirmation",
this.i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer })).then(data => {
if (data["confirm"]) {
console.log("ServiceWorkerUpdateService: application update confirmed");
window.location.reload();
......@@ -60,15 +61,14 @@ export class ServiceWorkerUpdateService {
break;
case 'VERSION_INSTALLATION_FAILED':
ver = (evt as any).version?.appData?.version ?? "NA";
console.log("ServiceWorkerUpdateService: VERSION_INSTALLATION_FAILED", ver);
notificationService.notify(i18nService.localizeText("ERROR_SERVICE_WORKER_INSTALL_FAILED", { "ver": ver }), 10000);
console.log(`Failed to install app version '${evt.version.hash}': ${evt.error}`);
this.notificationService.notify(this.i18nService.localizeText("ERROR_SERVICE_WORKER_INSTALL_FAILED"), 10000);
break;
}
});
swUpdate.unrecoverable.subscribe(event => {
console.log("SwUpdate.unrecoverable reason", event.reason, "type", event.type);
notificationService.notify("SwUpdate: unrecoverable state. Reason=" + event.reason + ", type=" + event.type, 10000);
this.notificationService.notify("SwUpdate: unrecoverable state. Reason=" + event.reason + ", type=" + event.type, 10000);
});
}
}
......@@ -678,7 +678,7 @@
"INFO_ESPECE_TITRE_COURT": "Species",
"INFO_SERVICE_WORKER_VERSION_DETECTED": "Downloading Cassiopée version %ver%...",
"INFO_SERVICE_WORKER_VERSION_READY": "Cassiopée version %ver% is ready to be used, please restart.",
"ERROR_SERVICE_WORKER_INSTALL_FAILED": "Cassiopée version %ver% installation failed.",
"ERROR_SERVICE_WORKER_INSTALL_FAILED": "Cassiopée new version installation failed.",
"ERROR_JET_SUBMERGED_NO_SOLUTION": "There is no solution",
"WARNING_DEVER_ZDV_INF_ZR": "Apron elevation of structure #%number% is below river bed elevation",
"WARNING_JET_START_SUBMERGED": "Water elevation is greater than jet start elevation",
......
......@@ -679,7 +679,7 @@
"INFO_ESPECE_TITRE_COURT": "Espèce",
"INFO_SERVICE_WORKER_VERSION_DETECTED": "Téléchargement de la version %ver% de Cassiopée en cours...",
"INFO_SERVICE_WORKER_VERSION_READY": "La version %ver% de Cassiopée est prête à être utilisée, veuillez redémarrer.",
"ERROR_SERVICE_WORKER_INSTALL_FAILED": "Erreur d'installation de Cassiopée version %ver%.",
"ERROR_SERVICE_WORKER_INSTALL_FAILED": "Erreur d'installation de la nouvelle version de Cassiopée.",
"ERROR_JET_SUBMERGED_NO_SOLUTION": "Il n'y a pas de solution",
"WARNING_DEVER_ZDV_INF_ZR": "La cote de radier de l'ouvrage n°%number% est sous la cote de fond du lit",
"WARNING_JET_START_SUBMERGED": "La cote de l'eau est supérieure à la cote de départ du jet",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment