simplify audit availability logic
This commit is contained in:
		
							parent
							
								
									2363631326
								
							
						
					
					
						commit
						c923a4bc22
					
				| @ -57,8 +57,8 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|   transactionsError: any = null; | ||||
|   overviewError: any = null; | ||||
|   webGlEnabled = true; | ||||
|   indexingAvailable = false; | ||||
|   auditModeEnabled: boolean = this.stateService.env.AUDIT && !this.stateService.hideAudit.value; | ||||
|   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; | ||||
|   showAudit: boolean; | ||||
|   isMobile = window.innerWidth <= 767.98; | ||||
| @ -109,11 +109,9 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|       this.timeLtr = !!ltr; | ||||
|     }); | ||||
| 
 | ||||
|     this.indexingAvailable = (this.stateService.env.BASE_MODULE === 'mempool' && this.stateService.env.MINING_DASHBOARD === true); | ||||
|     this.setAuditAvailable(this.auditSupported); | ||||
| 
 | ||||
|     this.setAuditAvailable(this.stateService.env.AUDIT && this.indexingAvailable); | ||||
| 
 | ||||
|     if (this.stateService.env.AUDIT) { | ||||
|     if (this.auditSupported) { | ||||
|       this.auditPrefSubscription = this.stateService.hideAudit.subscribe((hide) => { | ||||
|         this.auditModeEnabled = !hide; | ||||
|         this.showAudit = this.auditAvailable && this.auditModeEnabled; | ||||
| @ -224,7 +222,7 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|           setTimeout(() => { | ||||
|             this.nextBlockSubscription = this.apiService.getBlock$(block.previousblockhash).subscribe(); | ||||
|             this.nextBlockTxListSubscription = this.electrsApiService.getBlockTransactions$(block.previousblockhash).subscribe(); | ||||
|             if (this.stateService.env.AUDIT) { | ||||
|             if (this.auditSupported) { | ||||
|               this.apiService.getBlockAudit$(block.previousblockhash); | ||||
|             } | ||||
|           }, 100); | ||||
| @ -274,7 +272,7 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|       this.isLoadingOverview = false; | ||||
|     }); | ||||
| 
 | ||||
|     if (!this.indexingAvailable || !this.stateService.env.AUDIT) { | ||||
|     if (!this.auditSupported) { | ||||
|       this.overviewSubscription = block$.pipe( | ||||
|         startWith(null), | ||||
|         pairwise(), | ||||
| @ -305,7 +303,7 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|       }); | ||||
|     } | ||||
| 
 | ||||
|     if (this.indexingAvailable && this.stateService.env.AUDIT) { | ||||
|     if (this.auditSupported) { | ||||
|       this.auditSubscription = block$.pipe( | ||||
|         startWith(null), | ||||
|         pairwise(), | ||||
| @ -610,7 +608,7 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
| 
 | ||||
|   setAuditAvailable(available: boolean): void { | ||||
|     this.auditAvailable = available; | ||||
|     this.showAudit = this.auditAvailable && this.auditModeEnabled; | ||||
|     this.showAudit = this.auditAvailable && this.auditModeEnabled && this.auditSupported; | ||||
|   } | ||||
| 
 | ||||
|   toggleAuditMode(): void { | ||||
| @ -618,7 +616,7 @@ export class BlockComponent implements OnInit, OnDestroy { | ||||
|   } | ||||
| 
 | ||||
|   updateAuditAvailableFromBlockHeight(blockHeight: number): void { | ||||
|     if (!this.stateService.env.AUDIT) { | ||||
|     if (!this.auditSupported) { | ||||
|       this.setAuditAvailable(false); | ||||
|     } | ||||
|     switch (this.stateService.network) { | ||||
|  | ||||
| @ -14,7 +14,7 @@ | ||||
|           i18n-ngbTooltip="mining.pool-name" ngbTooltip="Pool" placement="bottom" #miningpool [disableTooltip]="!isEllipsisActive(miningpool)">Pool</th> | ||||
|         <th class="timestamp" i18n="latest-blocks.timestamp" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'">Timestamp</th> | ||||
|         <th class="mined" i18n="latest-blocks.mined" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'">Mined</th> | ||||
|         <th *ngIf="indexingAvailable && auditAvailable" class="health text-right" i18n="latest-blocks.health" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}" | ||||
|         <th *ngIf="auditAvailable" class="health text-right" i18n="latest-blocks.health" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}" | ||||
|           i18n-ngbTooltip="latest-blocks.health" ngbTooltip="Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Health</th> | ||||
|         <th *ngIf="indexingAvailable" class="reward text-right" i18n="latest-blocks.reward" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}" | ||||
|           i18n-ngbTooltip="latest-blocks.reward" ngbTooltip="Reward" placement="bottom" #reward [disableTooltip]="!isEllipsisActive(reward)">Reward</th> | ||||
| @ -45,7 +45,7 @@ | ||||
|           <td class="mined" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'"> | ||||
|             <app-time-since [time]="block.timestamp" [fastRender]="true"></app-time-since> | ||||
|           </td> | ||||
|           <td *ngIf="indexingAvailable && auditAvailable" class="health text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> | ||||
|           <td *ngIf="auditAvailable" class="health text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> | ||||
|             <a | ||||
|               class="health-badge badge" | ||||
|               [class.badge-success]="auditScores[block.id] >= 99" | ||||
| @ -98,7 +98,7 @@ | ||||
|             <td class="mined" *ngIf="!widget" [class]="indexingAvailable ? '' : 'legacy'"> | ||||
|               <span class="skeleton-loader" style="max-width: 125px"></span> | ||||
|             </td> | ||||
|             <td *ngIf="indexingAvailable && auditAvailable" class="health text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> | ||||
|             <td *ngIf="auditAvailable" class="health text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> | ||||
|               <span class="skeleton-loader" style="max-width: 75px"></span> | ||||
|             </td> | ||||
|             <td *ngIf="indexingAvailable" class="reward text-right" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> | ||||
|  | ||||
| @ -45,7 +45,7 @@ export class BlocksList implements OnInit, OnDestroy { | ||||
|   ngOnInit(): void { | ||||
|     this.indexingAvailable = (this.stateService.env.BASE_MODULE === 'mempool' && | ||||
|       this.stateService.env.MINING_DASHBOARD === true); | ||||
|     this.auditAvailable = this.stateService.env.AUDIT; | ||||
|     this.auditAvailable = this.indexingAvailable && this.stateService.env.AUDIT; | ||||
| 
 | ||||
|     if (!this.widget) { | ||||
|       this.websocketService.want(['blocks']); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user