diff --git a/front/dist/resources/service-worker.html b/front/dist/resources/service-worker.html deleted file mode 100644 index 45615b1a..00000000 --- a/front/dist/resources/service-worker.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - WorkAdventure PWA - - - - - WorkAdventure logo -

Charging your workspace ...

- - - \ No newline at end of file diff --git a/front/dist/resources/service-worker.js b/front/dist/resources/service-worker.js deleted file mode 100644 index d9509b6f..00000000 --- a/front/dist/resources/service-worker.js +++ /dev/null @@ -1,61 +0,0 @@ -let CACHE_NAME = 'workavdenture-cache-v1'; -let urlsToCache = [ - '/' -]; - -self.addEventListener('install', function(event) { - // Perform install steps - event.waitUntil( - caches.open(CACHE_NAME) - .then(function(cache) { - console.log('Opened cache'); - return cache.addAll(urlsToCache); - }) - ); -}); - -self.addEventListener('fetch', function(event) { - event.respondWith( - caches.match(event.request) - .then(function(response) { - // Cache hit - return response - if (response) { - return response; - } - - return fetch(event.request).then( - function(response) { - // Check if we received a valid response - if(!response || response.status !== 200 || response.type !== 'basic') { - return response; - } - - // IMPORTANT: Clone the response. A response is a stream - // and because we want the browser to consume the response - // as well as the cache consuming the response, we need - // to clone it so we have two streams. - var responseToCache = response.clone(); - - caches.open(CACHE_NAME) - .then(function(cache) { - cache.put(event.request, responseToCache); - }); - - return response; - } - ); - }) - ); -}); - -self.addEventListener('wait', function(event) { - //TODO wait -}); - -self.addEventListener('update', function(event) { - //TODO update -}); - -self.addEventListener('beforeinstallprompt', (e) => { - //TODO change prompt -}); \ No newline at end of file diff --git a/front/dist/static/images/favicons/apple-icon-114x114.png b/front/dist/static/images/favicons/apple-icon-114x114.png index 6c994217..fc41aaf4 100644 Binary files a/front/dist/static/images/favicons/apple-icon-114x114.png and b/front/dist/static/images/favicons/apple-icon-114x114.png differ diff --git a/front/dist/static/images/favicons/apple-icon-120x120.png b/front/dist/static/images/favicons/apple-icon-120x120.png index b20bf1e2..c1a99df6 100644 Binary files a/front/dist/static/images/favicons/apple-icon-120x120.png and b/front/dist/static/images/favicons/apple-icon-120x120.png differ diff --git a/front/dist/static/images/favicons/apple-icon-144x144.png b/front/dist/static/images/favicons/apple-icon-144x144.png index 59a7c4ce..4480a09a 100644 Binary files a/front/dist/static/images/favicons/apple-icon-144x144.png and b/front/dist/static/images/favicons/apple-icon-144x144.png differ diff --git a/front/dist/static/images/favicons/apple-icon-152x152.png b/front/dist/static/images/favicons/apple-icon-152x152.png index fc905367..766411c6 100644 Binary files a/front/dist/static/images/favicons/apple-icon-152x152.png and b/front/dist/static/images/favicons/apple-icon-152x152.png differ diff --git a/front/dist/static/images/favicons/apple-icon-180x180.png b/front/dist/static/images/favicons/apple-icon-180x180.png index 8f18bd51..65d4ef68 100644 Binary files a/front/dist/static/images/favicons/apple-icon-180x180.png and b/front/dist/static/images/favicons/apple-icon-180x180.png differ diff --git a/front/dist/static/images/favicons/apple-icon-57x57.png b/front/dist/static/images/favicons/apple-icon-57x57.png index 62c8ab07..754d1df8 100644 Binary files a/front/dist/static/images/favicons/apple-icon-57x57.png and b/front/dist/static/images/favicons/apple-icon-57x57.png differ diff --git a/front/dist/static/images/favicons/apple-icon-60x60.png b/front/dist/static/images/favicons/apple-icon-60x60.png index 68c5b74b..036c5aa0 100644 Binary files a/front/dist/static/images/favicons/apple-icon-60x60.png and b/front/dist/static/images/favicons/apple-icon-60x60.png differ diff --git a/front/dist/static/images/favicons/apple-icon-72x72.png b/front/dist/static/images/favicons/apple-icon-72x72.png index b04f1b25..71f1a11a 100644 Binary files a/front/dist/static/images/favicons/apple-icon-72x72.png and b/front/dist/static/images/favicons/apple-icon-72x72.png differ diff --git a/front/dist/static/images/favicons/apple-icon-76x76.png b/front/dist/static/images/favicons/apple-icon-76x76.png index a58cf3ed..3cc85751 100644 Binary files a/front/dist/static/images/favicons/apple-icon-76x76.png and b/front/dist/static/images/favicons/apple-icon-76x76.png differ diff --git a/front/dist/static/images/favicons/apple-icon.png b/front/dist/static/images/favicons/apple-icon.png index e1a4b3ed..f5bad500 100644 Binary files a/front/dist/static/images/favicons/apple-icon.png and b/front/dist/static/images/favicons/apple-icon.png differ diff --git a/front/dist/static/images/favicons/icon-512x512.png b/front/dist/static/images/favicons/icon-512x512.png index 86cb7477..41116386 100644 Binary files a/front/dist/static/images/favicons/icon-512x512.png and b/front/dist/static/images/favicons/icon-512x512.png differ diff --git a/front/dist/static/images/favicons/manifest.json b/front/dist/static/images/favicons/manifest.json index 9f9e9af1..1cf2a835 100644 --- a/front/dist/static/images/favicons/manifest.json +++ b/front/dist/static/images/favicons/manifest.json @@ -48,41 +48,10 @@ "type": "image\/png" }, { - "src": "/static/images/favicons/android-icon-36x36.png", - "sizes": "36x36", + "src": "/static/images/favicons/apple-icon.png", + "sizes": "192x192", "type": "image\/png", - "density": "0.75" - }, - { - "src": "/static/images/favicons/android-icon-48x48.png", - "sizes": "48x48", - "type": "image\/png", - "density": "1.0" - }, - { - "src": "/static/images/favicons/android-icon-72x72.png", - "sizes": "72x72", - "type": "image\/png", - "density": "1.5" - }, - - { - "src": "/static/images/favicons/favicon-16x16.png", - "sizes": "16x16", - "type": "image\/png", - "density": "1" - }, - { - "src": "/static/images/favicons/favicon-32x32.png", - "sizes": "32x32", - "type": "image\/png", - "density": "1.5" - }, - { - "src": "/static/images/favicons/favicon-96x96.png", - "sizes": "96x96", - "type": "image\/png", - "density": "2.0" + "purpose": "any" }, { @@ -122,18 +91,37 @@ "density": "4.0", "purpose": "any maskable" }, + + { + "src": "/static/images/favicons/favicon-16x16.png", + "sizes": "16x16", + "type": "image\/png", + "density": "1" + }, + { + "src": "/static/images/favicons/favicon-32x32.png", + "sizes": "32x32", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "/static/images/favicons/favicon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, { "src": "/static/images/favicons/icon-512x512.png", "sizes": "512x512", "type": "image\/png" } ], - "start_url": "/resources/service-worker.html", + "start_url": "/", "background_color": "#000000", "display_override": ["window-control-overlay", "minimal-ui"], "display": "standalone", "orientation": "portrait-primary", - "scope": "/resources/", + "scope": "/", "lang": "en", "theme_color": "#000000", "shortcuts": [ diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 11f03a9e..38272737 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -105,6 +105,15 @@ class ConnectionManager { let roomPath: string; if (connexionType === GameConnexionTypes.empty) { roomPath = window.location.protocol + "//" + window.location.host + START_ROOM_URL; + //get last room path from cache api + try { + const lastRoomUrl = await localUserStore.getLastRoomUrlCacheApi(); + if (lastRoomUrl != undefined) { + roomPath = lastRoomUrl; + } + } catch (err) { + console.error(err); + } } else { roomPath = window.location.protocol + diff --git a/front/src/Connexion/LocalUserStore.ts b/front/src/Connexion/LocalUserStore.ts index 07c2487e..25b673ac 100644 --- a/front/src/Connexion/LocalUserStore.ts +++ b/front/src/Connexion/LocalUserStore.ts @@ -17,6 +17,8 @@ const authToken = "authToken"; const state = "state"; const nonce = "nonce"; +const cacheAPIIndex = "workavdenture-cache-v1"; + class LocalUserStore { saveUser(localUser: LocalUser) { localStorage.setItem("localUser", JSON.stringify(localUser)); @@ -116,10 +118,23 @@ class LocalUserStore { setLastRoomUrl(roomUrl: string): void { localStorage.setItem(lastRoomUrl, roomUrl.toString()); + caches.open(cacheAPIIndex).then((cache) => { + const stringResponse = new Response(JSON.stringify({ roomUrl })); + cache.put(`/${lastRoomUrl}`, stringResponse); + }); } getLastRoomUrl(): string { return localStorage.getItem(lastRoomUrl) ?? ""; } + getLastRoomUrlCacheApi(): Promise { + return caches.open(cacheAPIIndex).then((cache) => { + return cache.match(`/${lastRoomUrl}`).then((res) => { + return res?.json().then((data) => { + return data.roomUrl; + }); + }); + }); + } setAuthToken(value: string | null) { value ? localStorage.setItem(authToken, value) : localStorage.removeItem(authToken); diff --git a/front/src/Network/ServiceWorker.ts b/front/src/Network/ServiceWorker.ts index 9bbcca85..59f913e2 100644 --- a/front/src/Network/ServiceWorker.ts +++ b/front/src/Network/ServiceWorker.ts @@ -6,15 +6,13 @@ export class _ServiceWorker { } init() { - window.addEventListener("load", () => { - navigator.serviceWorker - .register("/resources/service-worker.js") - .then((serviceWorker) => { - console.info("Service Worker registered: ", serviceWorker); - }) - .catch((error) => { - console.error("Error registering the Service Worker: ", error); - }); - }); + navigator.serviceWorker + .register("/service-worker.js") + .then((serviceWorker) => { + console.info("Service Worker registered: ", serviceWorker); + }) + .catch((error) => { + console.error("Error registering the Service Worker: ", error); + }); } }