add audit=[bool] param to block hash url

This commit is contained in:
russeree 2024-03-08 18:24:18 -08:00
parent bfde456ca8
commit fffffffdb3
No known key found for this signature in database
GPG key ID: C0AF3AD083D6B40A
2 changed files with 43 additions and 4 deletions

View file

@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of March 8, 2024.
Signed: PortlandHODL

View file

@ -61,6 +61,7 @@ export class BlockComponent implements OnInit, OnDestroy {
transactionsError: any = null;
overviewError: any = null;
webGlEnabled = true;
auditParamEnabled: boolean = false;
auditSupported: boolean = this.stateService.env.AUDIT && this.stateService.env.BASE_MODULE === 'mempool' && this.stateService.env.MINING_DASHBOARD === true;
auditModeEnabled: boolean = !this.stateService.hideAudit.value;
auditAvailable = true;
@ -124,11 +125,18 @@ export class BlockComponent implements OnInit, OnDestroy {
this.setAuditAvailable(this.auditSupported);
if (this.auditSupported) {
this.auditPrefSubscription = this.stateService.hideAudit.subscribe((hide) => {
this.isAuditEnabledFromParam().subscribe(auditParam => {
if (this.auditParamEnabled) {
console.log(`auditParamEnabled: ${auditParam}`);
this.auditModeEnabled = auditParam;
} else {
this.auditPrefSubscription = this.stateService.hideAudit.subscribe(hide => {
this.auditModeEnabled = !hide;
this.showAudit = this.auditAvailable && this.auditModeEnabled;
});
}
});
}
this.txsLoadingStatus$ = this.route.paramMap
.pipe(
@ -723,6 +731,24 @@ export class BlockComponent implements OnInit, OnDestroy {
toggleAuditMode(): void {
this.stateService.hideAudit.next(this.auditModeEnabled);
this.route.queryParams.subscribe(params => {
let queryParams = { ...params };
delete queryParams['audit'];
let newUrl = this.router.url.split('?')[0];
let queryString = new URLSearchParams(queryParams).toString();
if (queryString) {
newUrl += '?' + queryString;
}
this.location.replaceState(newUrl);
});
this.auditPrefSubscription = this.stateService.hideAudit.subscribe((hide) => {
this.auditModeEnabled = !hide;
this.showAudit = this.auditAvailable && this.auditModeEnabled;
});
}
updateAuditAvailableFromBlockHeight(blockHeight: number): void {
@ -731,6 +757,16 @@ export class BlockComponent implements OnInit, OnDestroy {
}
}
isAuditEnabledFromParam(): Observable<boolean> {
return this.route.queryParams.pipe(
map(params => {
this.auditParamEnabled = 'audit' in params;
return this.auditParamEnabled ? !(params['audit'] === 'false') : true;
})
);
}
isAuditAvailableFromBlockHeight(blockHeight: number): boolean {
if (!this.auditSupported) {
return false;