@cocreate/pwa 1.19.0 → 1.19.2
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/service-worker.js +15 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.19.2](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.19.1...v1.19.2) (2024-04-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* organization bug ([c3b5f22](https://github.com/CoCreate-app/CoCreate-pwa/commit/c3b5f22a929b56b2d294b46d30e90c684fa5415c))
|
|
7
|
+
|
|
8
|
+
## [1.19.1](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.19.0...v1.19.1) (2024-04-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* uncommented checkCache ([7372303](https://github.com/CoCreate-app/CoCreate-pwa/commit/737230325c59346687b699b3dfc0496be038f5a6))
|
|
14
|
+
|
|
1
15
|
# [1.19.0](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.18.2...v1.19.0) (2024-03-18)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/service-worker.js
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const cacheName = "dynamic-v2";
|
|
26
|
+
const updatedOn = new Date('2024-04-28T03:15:28.668Z');
|
|
27
|
+
|
|
26
28
|
let organization_id = ""
|
|
27
29
|
let storage = true
|
|
28
30
|
|
|
@@ -46,14 +48,23 @@ self.addEventListener("fetch", async (e) => {
|
|
|
46
48
|
caches
|
|
47
49
|
.match(e.request)
|
|
48
50
|
.then(async (cacheResponse) => {
|
|
49
|
-
|
|
51
|
+
let fetchedOn
|
|
52
|
+
if (cacheResponse && cacheType !== 'false') {
|
|
53
|
+
fetchedOn = cacheResponse.headers.get('fetched-on')
|
|
54
|
+
if (fetchedOn)
|
|
55
|
+
fetchedOn = new Date(fetchedOn)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if (!navigator.onLine || !!cacheResponse && cacheType !== 'false' && (!fetchedOn || fetchedOn > updatedOn)) {
|
|
50
60
|
const organization = cacheResponse.headers.get('organization')
|
|
61
|
+
console.log('servering cache fetchOn greater', fetchedOn > updatedOn, organization)
|
|
51
62
|
const lastModified = cacheResponse.headers.get('last-modified')
|
|
52
|
-
|
|
53
|
-
// returnedFromCache[e.request.url] = { organization, lastModified }
|
|
54
63
|
sendCacheUpdate(e.request.url, organization, lastModified);
|
|
55
64
|
return cacheResponse;
|
|
56
65
|
} else {
|
|
66
|
+
console.log('fetching fetchOn less', fetchedOn > updatedOn)
|
|
67
|
+
|
|
57
68
|
const networkResponse = await fetch(e.request);
|
|
58
69
|
|
|
59
70
|
if (!organization_id)
|
|
@@ -178,7 +189,7 @@ const sendCacheUpdate = (url, organization, lastModified) => {
|
|
|
178
189
|
});
|
|
179
190
|
|
|
180
191
|
fetchTimeout = null;
|
|
181
|
-
returnedFromCache = {};
|
|
192
|
+
// returnedFromCache = {};
|
|
182
193
|
}, 500);
|
|
183
194
|
};
|
|
184
195
|
|