@gudhub/core 1.2.4-beta.25 → 1.2.4-beta.26
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.
|
@@ -307,6 +307,27 @@ export class IndexedDBAppServiceForWorker extends AppDataService {
|
|
|
307
307
|
// });
|
|
308
308
|
// }
|
|
309
309
|
|
|
310
|
+
|
|
311
|
+
async getAppWithoutProcessing(id) {
|
|
312
|
+
let data = await this.dataService.getAppWithoutProcessing(id);
|
|
313
|
+
|
|
314
|
+
await this.putApp(id, data);
|
|
315
|
+
|
|
316
|
+
return data;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// this returns data for specific chunks + app request data
|
|
320
|
+
// async getAppWithSpecificChunksList(id, list) {
|
|
321
|
+
// let data = await this.dataService.getAppWithoutProcessing(id);
|
|
322
|
+
|
|
323
|
+
// await self.putApp(id, data);
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
// let processedData = await self.processRequestedApp(id, data);//here нужно пересмотреть
|
|
327
|
+
|
|
328
|
+
// return processedData;
|
|
329
|
+
// }
|
|
330
|
+
|
|
310
331
|
async getApp(id) {
|
|
311
332
|
// if (this.requestCache.has(id)) return this.requestCache.get(id);
|
|
312
333
|
|
|
@@ -40,33 +40,66 @@ self.onmessage = async function(e) {
|
|
|
40
40
|
let cached = await appDataService.getCached(e.data.id); // merge ?
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
let cachedChunksList = cached.chunks;
|
|
43
44
|
|
|
44
|
-
// TODO this is repetitive operation for getCached, maybe put all code in process or in getCached
|
|
45
45
|
|
|
46
|
-
let
|
|
46
|
+
let nextVersion = await appDataService.getAppWithoutProcessing(e.data.id);
|
|
47
47
|
|
|
48
|
-
// if (!res) res = [];
|
|
49
48
|
|
|
49
|
+
let isMergedChunkUpdated = true;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
cachedChunksList.length != nextVersion.chunks.length
|
|
54
|
+
) isMergedChunkUpdated = false;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
nextVersion.chunks.some(entry => !cachedChunksList.includes(entry))
|
|
59
|
+
) isMergedChunkUpdated = false;
|
|
52
60
|
|
|
53
61
|
|
|
54
62
|
if (
|
|
55
|
-
|
|
63
|
+
!isMergedChunkUpdated
|
|
56
64
|
) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
// TODO this is repetitive operation for getCached, maybe put all code in process or in getCached
|
|
67
|
+
|
|
68
|
+
let res = await chunkDataService.getCachedMergedChunk(e.data.id, cached.chunks);
|
|
69
|
+
|
|
70
|
+
// if (!res) res = [];
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// // TODO check that res always exists
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
res
|
|
78
|
+
) {
|
|
79
|
+
cached.items_list = await gudhub.util.mergeChunks([
|
|
80
|
+
// cachedApp,
|
|
81
|
+
res,
|
|
82
|
+
cached,
|
|
83
|
+
]);
|
|
84
|
+
} else {
|
|
85
|
+
// sentData.items_list = await this.gudhub.util.mergeChunks([
|
|
86
|
+
// cachedApp,
|
|
87
|
+
// sentData,
|
|
88
|
+
// ]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// nextVersion = await appDataService.getAppWithSpecificChunksList(e.data.id, newChunksList); //todo check that here most recent always
|
|
92
|
+
nextVersion = await appDataService.getApp(e.data.id); //todo check that here most recent always
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
//TODO тут достаточно сравнить новые чанки+апп и закешированный апп, тогда будет сгенерирована вся инфа о новых данных
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// return;
|
|
67
99
|
}
|
|
68
100
|
|
|
69
|
-
|
|
101
|
+
|
|
102
|
+
|
|
70
103
|
|
|
71
104
|
|
|
72
105
|
|