Strassenverwaltung plus: Teilen von Strassenzügen
This commit is contained in:
1 parent
d54a986c14
commit
3eb3b746ab
22 files changed
+17391
-158
No files matched your search
+26
-2
@@ -5,7 +5,7 @@
|
||||
* damit er sowohl die mobilen Views als auch die statischen Assets
|
||||
* kontrolliert. Der Cache-Name wird pro App-Wurzel gebildet.
|
||||
*/
|
||||
const VERSION = 'cmbnet-pwa-v14';
|
||||
const VERSION = 'cmbnet-pwa-v16';
|
||||
const BASE = new URL('./', self.location).href;
|
||||
const SHELL_CACHE = `${VERSION}-shell`;
|
||||
const TILE_CACHE = `${VERSION}-tiles`;
|
||||
@@ -18,7 +18,8 @@ const PRECACHE_PATHS = [
|
||||
'static/css/admin.css',
|
||||
'static/css/mobile.css',
|
||||
'static/js/leaflet.js',
|
||||
'static/js/str2pl.js',
|
||||
// str2pl.js bzw. str2pl-<tenant>.js wird nach der Registrierung gezielt
|
||||
// vom Client angemeldet, weil die passende Datei vom Mandanten abhängt.
|
||||
'static/js/reload_notice.js',
|
||||
'static/js/views/mobile.js',
|
||||
'static/img/logo.png',
|
||||
@@ -79,8 +80,31 @@ self.addEventListener('message', event => {
|
||||
if (event.data && event.data.type === 'SKIP_WAITING') {
|
||||
self.skipWaiting();
|
||||
}
|
||||
|
||||
if (event.data && event.data.type === 'CACHE_URLS' && Array.isArray(event.data.urls)) {
|
||||
event.waitUntil(cacheUrls(event.data.urls));
|
||||
}
|
||||
});
|
||||
|
||||
async function cacheUrls(urls) {
|
||||
const cache = await caches.open(SHELL_CACHE);
|
||||
await Promise.allSettled(
|
||||
urls.map(async url => {
|
||||
try {
|
||||
const cached = await cache.match(url);
|
||||
if (cached) return;
|
||||
|
||||
const response = await fetch(new Request(url, {cache: 'reload'}));
|
||||
if (response && (response.ok || response.type === 'opaque')) {
|
||||
await cache.put(url, response);
|
||||
}
|
||||
} catch (error) {
|
||||
// Einzelne fehlende Assets dürfen das Caching nicht verhindern.
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Fetch-Strategien */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
Reference in new issue
Block a user