From 6b9159b89c1baea3814cd85c7ef5a17a6cd428d8 Mon Sep 17 00:00:00 2001 From: natsoni Date: Wed, 20 Mar 2024 14:08:44 +0900 Subject: [PATCH] Add URL pagination to block transaction list --- frontend/src/app/components/block/block.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index c61fd0e12..6537faabd 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -302,8 +302,9 @@ export class BlockComponent implements OnInit, OnDestroy { throttleTime(300, asyncScheduler, { leading: true, trailing: true }), shareReplay(1) ); - this.transactionSubscription = block$.pipe( - switchMap((block) => this.electrsApiService.getBlockTransactions$(block.id) + this.transactionSubscription = combineLatest([block$, this.route.queryParams]).pipe( + tap(([_, queryParams]) => this.page = +queryParams['page'] || 1), + switchMap(([block, _]) => this.electrsApiService.getBlockTransactions$(block.id, (this.page - 1) * this.itemsPerPage) .pipe( catchError((err) => { this.transactionsError = err; @@ -592,6 +593,7 @@ export class BlockComponent implements OnInit, OnDestroy { this.transactions = null; this.transactionsError = null; target.scrollIntoView(); // works for chrome + this.router.navigate([], { queryParams: { page: page }, queryParamsHandling: 'merge' }); this.electrsApiService.getBlockTransactions$(this.block.id, start) .pipe(