@social-mail/social-mail-client 1.0.130 → 1.0.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/pwa/service-worker.js +47 -46
- package/package.json +1 -1
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const CACHE_NAME = "sw-smc-v1";
|
|
2
|
+
const urlsToCache = [
|
|
3
|
+
'/',
|
|
4
4
|
];
|
|
5
5
|
|
|
6
6
|
self.addEventListener('install', function (event) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
event.waitUntil(
|
|
8
|
+
caches.open(CACHE_NAME)
|
|
9
|
+
.then((cache) => {
|
|
10
|
+
console.log('Opened cache');
|
|
11
|
+
return cache.addAll(urlsToCache);
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
self.addEventListener('activate', function (event) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var cacheWhitelist = [CACHE_NAME];
|
|
18
|
+
event.waitUntil(
|
|
19
|
+
caches.keys().then((cacheNames) => {
|
|
20
|
+
return Promise.all(
|
|
21
|
+
cacheNames.map((cacheName) => {
|
|
22
|
+
if (cacheWhitelist.indexOf(cacheName) === -1) {
|
|
23
|
+
return caches.delete(cacheName);
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
);
|
|
25
27
|
})
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
);
|
|
28
|
+
);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
self.addEventListener('fetch',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
self.addEventListener('fetch', (event) => {
|
|
32
|
+
const request = event.request;
|
|
33
|
+
if (request.method !== 'GET') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const requestCopy = request.clone();
|
|
37
|
+
event.respondWith(
|
|
38
|
+
fetch(fetchRequest).then(
|
|
39
|
+
(response) => {
|
|
40
|
+
if (!response || response.status !== 200 || response.type !== 'basic') {
|
|
41
|
+
caches.match(requestCopy).then((cachedResponse) => {
|
|
42
|
+
if (cachedResponse) {
|
|
43
|
+
return cachedResponse;
|
|
44
|
+
}
|
|
45
|
+
return response;
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
var responseToCache = response.clone();
|
|
49
|
+
caches.open(CACHE_NAME)
|
|
50
|
+
.then((cache) => {
|
|
51
|
+
cache.put(event.request, responseToCache);
|
|
52
|
+
});
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
)
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
self.addEventListener("push", function(event) {
|