Merge pull request #4757 from russeree/add-aduit-blocks-param
Add audit=[bool] param to /block/[hash] url
This commit is contained in:
		
						commit
						acdc5f92cd
					
				
							
								
								
									
										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,11 +125,17 @@ 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) { | ||||
|           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 +730,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 +756,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; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user