- Conversione Codice... Errore Service Worker regostration.
- Sistemare quasar.config.ts di piuchebuono! -Le categorie non si vedono piu !!
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/* global importScripts */
|
||||
/* global idbKeyval */
|
||||
/* global workbox */
|
||||
/* global cfgenv */
|
||||
import { precacheAndRoute } from 'workbox-precaching';
|
||||
import { registerRoute } from 'workbox-routing';
|
||||
import { setCacheNameDetails } from 'workbox-core';
|
||||
@@ -164,6 +168,13 @@ if (workbox) {
|
||||
|
||||
registerRoute(new RegExp('/admin/'), new NetworkOnly());
|
||||
|
||||
function generateUUID() {
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const syncStore = {};
|
||||
self.addEventListener('message', event => {
|
||||
if (event.data && (event.data.type === 'SKIP_WAITING' || event.data.action === 'skipWaiting')) {
|
||||
@@ -171,7 +182,7 @@ if (workbox) {
|
||||
}
|
||||
if (event.data.type === 'sync') {
|
||||
console.log('addEventListener - message');
|
||||
const id = uuid();
|
||||
const id = generateUUID();
|
||||
syncStore[id] = event.data;
|
||||
self.registration.sync.register(id);
|
||||
}
|
||||
@@ -394,6 +405,7 @@ if (workbox) {
|
||||
let promiseChain = Promise.resolve();
|
||||
|
||||
for (let rec of myrecs) {
|
||||
//TODO: Risistemare con calma... per ora non penso venga usato...
|
||||
let link = cfgenv.serverweb + '/todos';
|
||||
if (method !== 'POST') link += '/' + rec._id;
|
||||
|
||||
@@ -436,13 +448,13 @@ if (workbox) {
|
||||
notification.close();
|
||||
} else {
|
||||
event.waitUntil(
|
||||
clients.matchAll().then((clis) => {
|
||||
self.clients.matchAll().then((clis) => {
|
||||
const client = clis.find((c) => c.visibilityState === 'visible');
|
||||
if (client) {
|
||||
client.navigate(notification.data.url);
|
||||
client.focus();
|
||||
} else {
|
||||
clients.openWindow(notification.data.url);
|
||||
self.clients.openWindow(notification.data.url);
|
||||
}
|
||||
notification.close();
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user