diff --git a/frontend/src/app/app.constants.ts b/frontend/src/app/app.constants.ts index 77baf3bfa..bfd80a03e 100644 --- a/frontend/src/app/app.constants.ts +++ b/frontend/src/app/app.constants.ts @@ -33,3 +33,5 @@ export const mempoolFeeColors = [ export const feeLevels = [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000]; + +export const ELCTRS_ITEMS_PER_PAGE = 25; diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 0bb90df60..4757afc95 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -76,12 +76,16 @@
-

{{ (transactions?.length | number) || '?' }} of {{ block.tx_count | number }} transactions

+

{{ block.tx_count | number }} transactions

- + -
- +
+ + + + +
@@ -94,12 +98,15 @@
+
- - + + + + @@ -158,3 +165,4 @@
+
diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index a7b723a5e..473a3e43d 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -7,6 +7,7 @@ import { Block, Transaction, Vout } from '../../interfaces/electrs.interface'; import { of } from 'rxjs'; import { StateService } from '../../services/state.service'; import { SeoService } from 'src/app/services/seo.service'; +import { ELCTRS_ITEMS_PER_PAGE } from 'src/app/app.constants'; @Component({ selector: 'app-block', @@ -25,6 +26,9 @@ export class BlockComponent implements OnInit, OnDestroy { error: any; blockSubsidy: number; fees: number; + paginationMaxSize: number; + page = 1; + itemsPerPage = ELCTRS_ITEMS_PER_PAGE; constructor( private route: ActivatedRoute, @@ -36,11 +40,14 @@ export class BlockComponent implements OnInit, OnDestroy { ) { } ngOnInit() { + this.paginationMaxSize = window.matchMedia('(max-width: 700px)').matches ? 3 : 5; + this.route.paramMap .pipe( switchMap((params: ParamMap) => { const blockHash: string = params.get('id') || ''; this.block = undefined; + this.page = 1; let isBlockHeight = false; this.error = undefined; this.fees = undefined; @@ -136,17 +143,15 @@ export class BlockComponent implements OnInit, OnDestroy { } } - loadMore() { - if (this.isLoadingTransactions || !this.transactions.length || this.transactions.length === this.block.tx_count) { - return; - } - + pageChange(page: number) { + const start = (page - 1) * this.itemsPerPage; this.isLoadingTransactions = true; - this.electrsApiService.getBlockTransactions$(this.block.id, this.transactions.length) - .subscribe((transactions) => { - this.transactions = this.transactions.concat(transactions); + this.transactions = null; + + this.electrsApiService.getBlockTransactions$(this.block.id, start) + .subscribe((transactions) => { + this.transactions = transactions; this.isLoadingTransactions = false; }); } - }