mirror of
https://github.com/mempool/mempool.git
synced 2025-02-22 06:21:46 +01:00
add audit=[bool] param to block hash url
This commit is contained in:
parent
bfde456ca8
commit
fffffffdb3
2 changed files with 43 additions and 4 deletions
3
contributors/russeree.txt
Normal file
3
contributors/russeree.txt
Normal 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
|
|
@ -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,9 +125,16 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||
this.setAuditAvailable(this.auditSupported);
|
||||
|
||||
if (this.auditSupported) {
|
||||
this.auditPrefSubscription = this.stateService.hideAudit.subscribe((hide) => {
|
||||
this.auditModeEnabled = !hide;
|
||||
this.showAudit = this.auditAvailable && this.auditModeEnabled;
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -779,4 +815,4 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||
this.block.canonical = block.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue