diff --git a/apps/browser/src/tools/popup/send-v2/send-v2.component.html b/apps/browser/src/tools/popup/send-v2/send-v2.component.html index 698901d846..23582f1911 100644 --- a/apps/browser/src/tools/popup/send-v2/send-v2.component.html +++ b/apps/browser/src/tools/popup/send-v2/send-v2.component.html @@ -1,4 +1,4 @@ - + diff --git a/apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts b/apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts index 63e3c2d2fc..506d7146dd 100644 --- a/apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts +++ b/apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts @@ -59,6 +59,7 @@ describe("SendV2Component", () => { { id: "1", name: "Send A" }, { id: "2", name: "Send B" }, ] as SendView[]), + loading$: of(false), latestSearchText$: of(""), }); diff --git a/apps/browser/src/tools/popup/send-v2/send-v2.component.ts b/apps/browser/src/tools/popup/send-v2/send-v2.component.ts index 26a995e8c4..2766ba56c9 100644 --- a/apps/browser/src/tools/popup/send-v2/send-v2.component.ts +++ b/apps/browser/src/tools/popup/send-v2/send-v2.component.ts @@ -55,6 +55,7 @@ export class SendV2Component implements OnInit, OnDestroy { protected listState: SendState | null = null; protected sends$ = this.sendItemsService.filteredAndSortedSends$; + protected sendsLoading$ = this.sendItemsService.loading$; protected title: string = "allSends"; protected noItemIcon = NoSendsIcon; protected noResultsIcon = Icons.NoResults; diff --git a/libs/tools/send/send-ui/src/services/send-items.service.spec.ts b/libs/tools/send/send-ui/src/services/send-items.service.spec.ts index 92a48df40a..7a7c86df92 100644 --- a/libs/tools/send/send-ui/src/services/send-items.service.spec.ts +++ b/libs/tools/send/send-ui/src/services/send-items.service.spec.ts @@ -62,9 +62,15 @@ describe("SendItemsService", () => { it("should update loading$ when sends are loading", (done) => { const sendsLoading$ = new Subject(); (service as any)._sendsLoading$ = sendsLoading$; + let sendLoadingIndex = 0; service.loading$.subscribe((loading) => { - expect(loading).toBe(true); - done(); + if (sendLoadingIndex === 0) { + expect(loading).toBe(true); + sendLoadingIndex++; + } else { + expect(loading).toBe(false); + done(); + } }); sendsLoading$.next(); diff --git a/libs/tools/send/send-ui/src/services/send-items.service.ts b/libs/tools/send/send-ui/src/services/send-items.service.ts index 107749b1e6..66ad5b6786 100644 --- a/libs/tools/send/send-ui/src/services/send-items.service.ts +++ b/libs/tools/send/send-ui/src/services/send-items.service.ts @@ -5,6 +5,7 @@ import { distinctUntilChanged, from, map, + merge, Observable, shareReplay, startWith, @@ -47,7 +48,9 @@ export class SendItemsService { this._searchText$, this.sendListFiltersService.filterFunction$, ]).pipe( - tap(() => this._sendsLoading$.next()), + tap(() => { + this._sendsLoading$.next(); + }), map(([sends, searchText, filterFunction]): [SendView[], string] => [ filterFunction(sends), searchText, @@ -60,9 +63,10 @@ export class SendItemsService { /** * Observable that indicates whether the service is currently loading sends. */ - loading$: Observable = this._sendsLoading$ - .pipe(map(() => true)) - .pipe(startWith(true), distinctUntilChanged(), shareReplay({ refCount: false, bufferSize: 1 })); + loading$: Observable = merge( + this._sendsLoading$.pipe(map(() => true)), + this.filteredAndSortedSends$.pipe(map(() => false)), + ).pipe(startWith(true), distinctUntilChanged(), shareReplay({ refCount: false, bufferSize: 1 })); /** * Observable that indicates whether a filter is currently applied to the sends.