Adding missing error output on /blocks page.

This commit is contained in:
softsimon 2021-01-10 22:41:52 +07:00
parent 9689ccf2ac
commit e36646ac7c
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 23 additions and 1 deletions

View File

@ -46,4 +46,12 @@
</tbody>
</table>
<ng-template [ngIf]="error">
<div class="text-center">
<span>Error loading blocks</span>
<br>
<i>{{ error.error }}</i>
</div>
</ng-template>
</div>

View File

@ -15,7 +15,7 @@ import { map } from 'rxjs/operators';
})
export class LatestBlocksComponent implements OnInit, OnDestroy {
network$: Observable<string>;
error: any;
blocks: any[] = [];
blockSubscription: Subscription;
isLoading = true;
@ -86,6 +86,7 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
.subscribe((blocks) => {
this.blocks = blocks;
this.isLoading = false;
this.error = undefined;
this.latestBlockHeight = blocks[0].height;
@ -95,6 +96,12 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
this.loadMore(chunks);
}
this.cd.markForCheck();
},
(error) => {
console.log(error);
this.error = error;
this.isLoading = false;
this.cd.markForCheck();
});
}
@ -107,12 +114,19 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
.subscribe((blocks) => {
this.blocks = this.blocks.concat(blocks);
this.isLoading = false;
this.error = undefined;
const chunksLeft = chunks - 1;
if (chunksLeft > 0) {
this.loadMore(chunksLeft);
}
this.cd.markForCheck();
},
(error) => {
console.log(error);
this.error = error;
this.isLoading = false;
this.cd.markForCheck();
});
}