Skip to content

Commit 993e93e

Browse files
committed
Fix pagination on scan state page
1 parent dd30271 commit 993e93e

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

frontend/src/app/features/snarks/scan-state/scan-state-toolbar/scan-state-toolbar.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
class="h-sm w-sm fx-row-full-cent"
4040
[tooltip]="'Next block'"
4141
[showDelay]="500"
42-
[disabled]="block?.trees.length === 0"
42+
[disabled]="
43+
block?.trees.length === 0 || block?.height >= maxBlockHeight
44+
"
4345
(click)="clearForm(); getHeight(block?.height + 1)"
4446
>
4547
<span class="mina-icon f-18">navigate_next</span>

frontend/src/app/features/snarks/scan-state/scan-state-toolbar/scan-state-toolbar.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
import { FormBuilder, FormGroup } from '@angular/forms';
3636
import { untilDestroyed } from '@ngneat/until-destroy';
3737
import { NumberInput } from '@angular/cdk/coercion';
38+
import { AppSelectors } from '@app/app.state';
39+
import { AppNodeDetails } from '@shared/types/app/app-node-details.type';
3840

3941
@Component({
4042
selector: 'mina-scan-state-toolbar',
@@ -54,6 +56,7 @@ export class ScanStateToolbarComponent
5456
openSidePanel: boolean;
5557
treeView: boolean;
5658
highlightSnarkPool: boolean;
59+
maxBlockHeight: number;
5760

5861
private inputRef: ElementRef<HTMLInputElement>;
5962
private gotHeightFromForm: boolean;
@@ -76,6 +79,7 @@ export class ScanStateToolbarComponent
7679
this.listenToSidePanelChange();
7780
this.listenToTreeViewChange();
7881
this.listenToHighlightSnarkPoolChange();
82+
this.listenToActiveNodeDetailsChanges();
7983
}
8084

8185
getHeight(height: NumberInput): void {
@@ -196,4 +200,11 @@ export class ScanStateToolbarComponent
196200
toggleHighlightSnarkPool(): void {
197201
this.dispatch(ScanStateHighlightSnarkPool);
198202
}
203+
204+
private listenToActiveNodeDetailsChanges(): void {
205+
this.select(AppSelectors.activeNodeDetails, (details: AppNodeDetails) => {
206+
this.maxBlockHeight = details?.blockHeight;
207+
this.detect();
208+
});
209+
}
199210
}

frontend/src/app/features/snarks/scan-state/scan-state.service.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
tap,
1111
} from 'rxjs';
1212
import { ScanStateBlock } from '@shared/types/snarks/scan-state/scan-state-block.type';
13-
import { HttpClient } from '@angular/common/http';
13+
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
1414
import {
1515
ScanStateLeaf,
1616
ScanStateLeafStatus,
@@ -32,7 +32,7 @@ export class ScanStateService {
3232
) {}
3333

3434
getScanState(heightOrHash?: string | number): Observable<ScanStateBlock> {
35-
const url = this.rust.URL + '/scan-state/summary/' + (heightOrHash ?? '');
35+
const url = `${this.rust.URL}/scan-state/summary/${heightOrHash ?? ''}`;
3636

3737
return this.http.get<any>(url).pipe(
3838
switchMap((response: any[]) => {
@@ -84,8 +84,22 @@ export class ScanStateService {
8484
map(() => response),
8585
);
8686
}),
87-
8887
map((response: any) => this.mapScanState(response)),
88+
catchError((err: HttpErrorResponse) => {
89+
const response = err.error;
90+
if (response === 'target block not found') {
91+
return of({
92+
hash: '',
93+
height: 0,
94+
globalSlot: 0,
95+
transactions: [],
96+
completedWorks: [],
97+
workingSnarkers: [],
98+
trees: [],
99+
});
100+
}
101+
throw new Error(response);
102+
}),
89103
);
90104
}
91105

0 commit comments

Comments
 (0)