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