@ethlete/query 2.9.0 → 2.9.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/esm2020/lib/directives/infinity-query.directive.mjs +14 -6
- package/esm2020/lib/query/query.mjs +4 -1
- package/esm2020/lib/request/request.mjs +1 -1
- package/fesm2015/ethlete-query.mjs +16 -5
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +16 -5
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/infinity-query.directive.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i1 from '@ethlete/core';
|
|
2
2
|
import { BehaviorSubjectWithSubscriberCount, getCookie, setCookie, deleteCookie, DestroyService, DelayableDirective, equal, clone } from '@ethlete/core';
|
|
3
|
-
import { Observable, filter, takeWhile, switchMap, of, BehaviorSubject, Subject, takeUntil, tap, interval, startWith, finalize, timer, map, combineLatest, fromEvent, debounceTime, take, concat, distinctUntilChanged } from 'rxjs';
|
|
3
|
+
import { Observable, filter, takeWhile, switchMap, of, BehaviorSubject, Subject, takeUntil, tap, interval, startWith, finalize, timer, map, combineLatest, skip, fromEvent, debounceTime, take, concat, distinctUntilChanged } from 'rxjs';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
5
|
import { Directive, Input, InjectionToken, inject, ChangeDetectorRef, ViewContainerRef, TemplateRef, ErrorHandler, ElementRef } from '@angular/core';
|
|
6
6
|
import { FormGroup } from '@angular/forms';
|
|
@@ -937,6 +937,9 @@ class Query {
|
|
|
937
937
|
}))
|
|
938
938
|
.subscribe();
|
|
939
939
|
}
|
|
940
|
+
else {
|
|
941
|
+
failure();
|
|
942
|
+
}
|
|
940
943
|
}
|
|
941
944
|
else if (state.type === 'cancel') {
|
|
942
945
|
this._state$.next({
|
|
@@ -1508,6 +1511,7 @@ class InfinityQueryDirective {
|
|
|
1508
1511
|
this._errorHandler = inject(ErrorHandler);
|
|
1509
1512
|
this._delayable = inject(DelayableDirective, { host: true });
|
|
1510
1513
|
this._data$ = new BehaviorSubject([]);
|
|
1514
|
+
this._didReceiveFirstData$ = new BehaviorSubject(false);
|
|
1511
1515
|
this._isMainViewCreated = false;
|
|
1512
1516
|
}
|
|
1513
1517
|
get infinityQuery() {
|
|
@@ -1542,15 +1546,19 @@ class InfinityQueryDirective {
|
|
|
1542
1546
|
}
|
|
1543
1547
|
_setupInfinityQuery(config) {
|
|
1544
1548
|
const instance = new InfinityQuery(config);
|
|
1545
|
-
combineLatest([
|
|
1546
|
-
.pipe(
|
|
1549
|
+
combineLatest([
|
|
1550
|
+
instance.currentQuery$.pipe(switchQueryState()),
|
|
1551
|
+
this._delayable.isDelayed$,
|
|
1552
|
+
this._didReceiveFirstData$,
|
|
1553
|
+
])
|
|
1554
|
+
.pipe(tap(([state, isDelayed, didReceiveFirstData]) => {
|
|
1547
1555
|
this._viewContext.currentPage = instance.currentPage;
|
|
1548
1556
|
this._viewContext.totalPages = instance.totalPages;
|
|
1549
1557
|
this._viewContext.itemsPerPage = instance.itemsPerPage;
|
|
1550
1558
|
this._viewContext.canLoadMore =
|
|
1551
1559
|
(instance.totalPages && instance.currentPage && instance.totalPages > instance.currentPage) || false;
|
|
1552
1560
|
this._viewContext.currentCalculatedPage = instance.currentCalculatedPage;
|
|
1553
|
-
if (isQueryStateLoading(state) || isDelayed) {
|
|
1561
|
+
if (isQueryStateLoading(state) || isDelayed || (!didReceiveFirstData && isQueryStateSuccess(state))) {
|
|
1554
1562
|
this._viewContext.loading = true;
|
|
1555
1563
|
this._viewContext.error = null;
|
|
1556
1564
|
this._viewContext.isFirstLoad = this.context.infinityQuery === null;
|
|
@@ -1582,9 +1590,12 @@ class InfinityQueryDirective {
|
|
|
1582
1590
|
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
1583
1591
|
.subscribe();
|
|
1584
1592
|
instance.data$
|
|
1585
|
-
.pipe(tap((data) => {
|
|
1593
|
+
.pipe(skip(1), tap((data) => {
|
|
1586
1594
|
this._viewContext.infinityQuery = this._viewContext.$implicit = data;
|
|
1587
1595
|
this._data$.next(data);
|
|
1596
|
+
if (!this._didReceiveFirstData$.getValue()) {
|
|
1597
|
+
this._didReceiveFirstData$.next(true);
|
|
1598
|
+
}
|
|
1588
1599
|
this._cdr.markForCheck();
|
|
1589
1600
|
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
1590
1601
|
.subscribe();
|