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 @@ ...@@ -19,12 +19,12 @@
"/*.css", "/*.css",
"/*.js", "/*.js",
"/*.json", "/*.json",
"/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2|eot)",
"/3rdpartylicenses.txt", "/3rdpartylicenses.txt",
"/MaterialIcons-Regular.1e50f5c2ffa6aba4.eot",
"/assets/**", "/assets/**",
"!/**/*.pdf", "!/**/*.pdf",
"!/**/*.php", "!/**/*.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"; ...@@ -5,7 +5,7 @@ import { NotificationsService } from "./notifications.service";
import { UserConfirmationService } from "./user-confirmation.service"; import { UserConfirmationService } from "./user-confirmation.service";
import { interval } from "rxjs"; import { interval } from "rxjs";
@Injectable() @Injectable({providedIn: 'root'})
export class ServiceWorkerUpdateService { export class ServiceWorkerUpdateService {
constructor( constructor(
private swUpdate: SwUpdate, private swUpdate: SwUpdate,
...@@ -28,11 +28,12 @@ export class ServiceWorkerUpdateService { ...@@ -28,11 +28,12 @@ export class ServiceWorkerUpdateService {
} }
this.swUpdate.versionUpdates.subscribe(evt => { this.swUpdate.versionUpdates.subscribe(evt => {
console.log("ServiceWorkerUpdateService event:", evt.type);
switch (evt.type) { switch (evt.type) {
case 'VERSION_DETECTED': case 'VERSION_DETECTED':
let ver = (evt as any).version?.appData?.version ?? "<NA>"; let ver = (evt as any).version?.appData?.version ?? "<NA>";
console.log("ServiceWorkerUpdateService: VERSION_DETECTED", ver); 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; break;
case 'VERSION_READY': case 'VERSION_READY':
...@@ -40,15 +41,15 @@ export class ServiceWorkerUpdateService { ...@@ -40,15 +41,15 @@ export class ServiceWorkerUpdateService {
const newVer = (evt as any).latestVersion?.appData?.version ?? "<NA>"; const newVer = (evt as any).latestVersion?.appData?.version ?? "<NA>";
console.log("ServiceWorkerUpdateService: VERSION_READY", currVer, "->", newVer); 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 !!!! // PLANTE si on stocke le message dans une variable !!!!
// const msg = i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer }); // const msg = i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer });
// notificationService.notify(msg, 10000); // notificationService.notify(msg, 10000);
// -> ReferenceError: can't access lexical declaration 'xxx' before initialization // -> ReferenceError: can't access lexical declaration 'xxx' before initialization
// avec xxx qui varie d'une fois à l'autre !!! // avec xxx qui varie d'une fois à l'autre !!!
userConfirmationService.askUserConfirmation("Confirmation", this.userConfirmationService.askUserConfirmation("Confirmation",
i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer })).then(data => { this.i18nService.localizeText("INFO_SERVICE_WORKER_VERSION_READY", { "ver": newVer })).then(data => {
if (data["confirm"]) { if (data["confirm"]) {
console.log("ServiceWorkerUpdateService: application update confirmed"); console.log("ServiceWorkerUpdateService: application update confirmed");
window.location.reload(); window.location.reload();
...@@ -60,15 +61,14 @@ export class ServiceWorkerUpdateService { ...@@ -60,15 +61,14 @@ export class ServiceWorkerUpdateService {
break; break;
case 'VERSION_INSTALLATION_FAILED': case 'VERSION_INSTALLATION_FAILED':
ver = (evt as any).version?.appData?.version ?? "NA"; console.log(`Failed to install app version '${evt.version.hash}': ${evt.error}`);
console.log("ServiceWorkerUpdateService: VERSION_INSTALLATION_FAILED", ver); this.notificationService.notify(this.i18nService.localizeText("ERROR_SERVICE_WORKER_INSTALL_FAILED"), 10000);
notificationService.notify(i18nService.localizeText("ERROR_SERVICE_WORKER_INSTALL_FAILED", { "ver": ver }), 10000);
break; break;
} }
}); });
swUpdate.unrecoverable.subscribe(event => { swUpdate.unrecoverable.subscribe(event => {
console.log("SwUpdate.unrecoverable reason", event.reason, "type", event.type); 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 @@ ...@@ -678,7 +678,7 @@
"INFO_ESPECE_TITRE_COURT": "Species", "INFO_ESPECE_TITRE_COURT": "Species",
"INFO_SERVICE_WORKER_VERSION_DETECTED": "Downloading Cassiopée version %ver%...", "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.", "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", "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_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", "WARNING_JET_START_SUBMERGED": "Water elevation is greater than jet start elevation",
......
...@@ -679,7 +679,7 @@ ...@@ -679,7 +679,7 @@
"INFO_ESPECE_TITRE_COURT": "Espèce", "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_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.", "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", "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_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", "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