Add URL pagination to block transaction list

This commit is contained in:
natsoni 2024-03-20 14:08:44 +09:00
parent f6dbe1e17f
commit 6b9159b89c
No known key found for this signature in database
GPG Key ID: C65917583181743B

View File

@ -302,8 +302,9 @@ export class BlockComponent implements OnInit, OnDestroy {
throttleTime(300, asyncScheduler, { leading: true, trailing: true }), throttleTime(300, asyncScheduler, { leading: true, trailing: true }),
shareReplay(1) shareReplay(1)
); );
this.transactionSubscription = block$.pipe( this.transactionSubscription = combineLatest([block$, this.route.queryParams]).pipe(
switchMap((block) => this.electrsApiService.getBlockTransactions$(block.id) tap(([_, queryParams]) => this.page = +queryParams['page'] || 1),
switchMap(([block, _]) => this.electrsApiService.getBlockTransactions$(block.id, (this.page - 1) * this.itemsPerPage)
.pipe( .pipe(
catchError((err) => { catchError((err) => {
this.transactionsError = err; this.transactionsError = err;
@ -592,6 +593,7 @@ export class BlockComponent implements OnInit, OnDestroy {
this.transactions = null; this.transactions = null;
this.transactionsError = null; this.transactionsError = null;
target.scrollIntoView(); // works for chrome target.scrollIntoView(); // works for chrome
this.router.navigate([], { queryParams: { page: page }, queryParamsHandling: 'merge' });
this.electrsApiService.getBlockTransactions$(this.block.id, start) this.electrsApiService.getBlockTransactions$(this.block.id, start)
.pipe( .pipe(