@elderbyte/ngx-starter 19.13.1 → 19.13.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.
|
@@ -6583,10 +6583,10 @@ class CuratedDataSource {
|
|
|
6583
6583
|
return this._dataChanged;
|
|
6584
6584
|
}
|
|
6585
6585
|
findById(id) {
|
|
6586
|
-
return this.originalSource.findById(id);
|
|
6586
|
+
return this.readyUseCurated$.pipe(switchMap$1((useCurated) => this.curatedData.findById(id)), catchError((err) => this.originalSource.findById(id)));
|
|
6587
6587
|
}
|
|
6588
6588
|
findByIds(ids) {
|
|
6589
|
-
return this.
|
|
6589
|
+
return this.readyUseCurated$.pipe(switchMap$1((useCurated) => this.findByIdsFirstCuratedThenOriginal(ids)));
|
|
6590
6590
|
}
|
|
6591
6591
|
getId(entity) {
|
|
6592
6592
|
return this.originalSource.getId(entity);
|
|
@@ -6604,6 +6604,28 @@ class CuratedDataSource {
|
|
|
6604
6604
|
const curatedEvents$ = this.curatedData.dataChanged.pipe(combineLatestWith(this.useCuratedData$), filter(([_, enabled]) => enabled), map(([event, _]) => event));
|
|
6605
6605
|
return genericEvents$.pipe(mergeWith(curatedEvents$));
|
|
6606
6606
|
}
|
|
6607
|
+
findByIdsFirstCuratedThenOriginal(ids) {
|
|
6608
|
+
const desiredIds = new Set(ids);
|
|
6609
|
+
const curated = this.findAvailableCuratedByIds(desiredIds);
|
|
6610
|
+
const missingIds = new Set(ids);
|
|
6611
|
+
curated.forEach((entity, id) => missingIds.delete(id));
|
|
6612
|
+
const curatedEntities = Array.from(curated.values());
|
|
6613
|
+
if (missingIds.size > 0) {
|
|
6614
|
+
return this.originalSource
|
|
6615
|
+
.findByIds(Array.from(missingIds))
|
|
6616
|
+
.pipe(map((missing) => [...missing, ...curatedEntities]));
|
|
6617
|
+
}
|
|
6618
|
+
else {
|
|
6619
|
+
return of(curatedEntities);
|
|
6620
|
+
}
|
|
6621
|
+
}
|
|
6622
|
+
findAvailableCuratedByIds(desiredIds) {
|
|
6623
|
+
const map = new Map();
|
|
6624
|
+
this.curatedData.data
|
|
6625
|
+
.filter((e) => desiredIds.has(this.getId(e)))
|
|
6626
|
+
.forEach((e) => map.set(this.getId(e), e));
|
|
6627
|
+
return map;
|
|
6628
|
+
}
|
|
6607
6629
|
}
|
|
6608
6630
|
|
|
6609
6631
|
/**
|