diff --git a/src/App.vue b/src/App.vue
index 173e73d..c63cdf3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -20,6 +20,7 @@
/>
+
{{
title
}}
@@ -43,15 +44,19 @@
>
@@ -62,7 +67,6 @@
-
diff --git a/src/components/QueueNotif.vue b/src/components/QueueNotif.vue
index 78b5497..3d18181 100644
--- a/src/components/QueueNotif.vue
+++ b/src/components/QueueNotif.vue
@@ -1,5 +1,7 @@
-
+
+ nouvelle version dispoible
+
diff --git a/src/registerServiceWorker.ts b/src/registerServiceWorker.ts
index 96f5cd4..176da00 100644
--- a/src/registerServiceWorker.ts
+++ b/src/registerServiceWorker.ts
@@ -1,20 +1,9 @@
/* tslint:disable:no-console */
import { register } from 'register-service-worker'
-import QueueNotifService from '@/services/QueueNotifService'
+import queueNotifService from '@/services/QueueNotifService'
if (process.env.NODE_ENV === 'production') {
- const enableNotif: boolean = false
- let newWorker: any | undefined
-
- const reloadLink = document.getElementById('reload-notify-worker')
- if (reloadLink) {
- reloadLink.addEventListener('click', () => {
- if (newWorker) {
- newWorker.postMessage({ action: 'skipWaiting' })
- }
- })
- }
register(`${process.env.BASE_URL}service-worker.js`, {
registrationOptions: {},
ready() {
@@ -22,30 +11,11 @@ if (process.env.NODE_ENV === 'production') {
},
cached() {
console.log('Content has been cached for offline use.')
- QueueNotifService.success('Application mise à jour !')
- },
- updatefound(reg) {
- if (enableNotif) {
- console.log('New content found;')
- newWorker = reg.installing
-
- newWorker.addEventListener('statechange', () => {
- // Has network.state changed?
- switch (newWorker.state) {
- case 'installed':
- if (navigator.serviceWorker.controller) {
- // new update available
- // showUpdateBar()
- }
- // No update available
- break
- }
- })
- }
+ queueNotifService.success('Application mise à jour !')
},
updated() {
console.log('New content is available; please refresh.')
- location.reload(true)
+ queueNotifService.hasNewVersion()
},
offline() {
console.log(
diff --git a/src/services/QueueNotifService.ts b/src/services/QueueNotifService.ts
index e06c8ca..09a2eaf 100644
--- a/src/services/QueueNotifService.ts
+++ b/src/services/QueueNotifService.ts
@@ -6,6 +6,12 @@ interface QueueNotif {
class QueueNotifService {
private queue: QueueNotif[] = []
private callback: ((notif: QueueNotif) => void) | null = null
+ private newVersion = false
+ private newVersionCallback: ((newVersion: boolean) => void) | null = null
+
+ public get getNewVersion() {
+ return this.newVersion
+ }
public success(message: string) {
this.add({
@@ -32,6 +38,18 @@ class QueueNotifService {
this.callback = null
}
+ public hasNewVersion() {
+ this.newVersion = true
+ if (this.newVersionCallback) {
+ this.newVersionCallback(this.newVersion)
+ }
+ }
+
+ public subscribeToNewVersion(callback: (newVersion: boolean) => void) {
+ this.newVersionCallback = callback
+ this.newVersionCallback(this.newVersion)
+ }
+
private add(notif: QueueNotif) {
this.queue.push(notif)
if (this.callback) {
diff --git a/src/styles/index.scss b/src/styles/index.scss
index 44222c6..af51ea2 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -57,12 +57,10 @@ button {
$navbar-color: #eaeaea4d;
-.navbar-menu {
- .navbar-item {
- border: 2px solid $navbar-color;
- border-radius: 10px;
- margin: 5px;
- }
+.navbar-item.nav-button {
+ border: 2px solid $navbar-color;
+ border-radius: 10px;
+ margin: 5px;
}
.title,