Fix custom dashboard address graph
This commit is contained in:
		
							parent
							
								
									0fcd132df4
								
							
						
					
					
						commit
						9495d7d2ea
					
				| @ -73,7 +73,7 @@ export class AddressGraphComponent implements OnChanges, OnDestroy { | ||||
|     if (!this.address || !this.stats) { | ||||
|       return; | ||||
|     } | ||||
|     if (changes.address || changes.isPubkey || changes.addressSummary$) { | ||||
|     if (changes.address || changes.isPubkey || changes.addressSummary$ || changes.stats) { | ||||
|       if (this.subscription) { | ||||
|         this.subscription.unsubscribe(); | ||||
|       } | ||||
| @ -248,7 +248,9 @@ export class AddressGraphComponent implements OnChanges, OnDestroy { | ||||
|   } | ||||
| 
 | ||||
|   ngOnDestroy(): void { | ||||
|     this.subscription.unsubscribe(); | ||||
|     if (this.subscription) { | ||||
|       this.subscription.unsubscribe(); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   isMobile() { | ||||
|  | ||||
| @ -238,7 +238,7 @@ | ||||
|                   <span> </span> | ||||
|                   <fa-icon [icon]="['fas', 'external-link-alt']" [fixedWidth]="true" style="vertical-align: text-top; font-size: 13px; color: var(--title-fg)"></fa-icon> | ||||
|                 </a> | ||||
|                 <app-address-graph [address]="widget.props.address" [addressSummary$]="addressSummary$" [period]="widget.props.period || 'all'" [stats]="address?.chain_stats" [widget]="true" [height]="graphHeight"></app-address-graph> | ||||
|                 <app-address-graph [address]="widget.props.address" [addressSummary$]="addressSummary$" [period]="widget.props.period || 'all'" [stats]="address ? address.chain_stats : null" [widget]="true" [height]="graphHeight"></app-address-graph> | ||||
|               </div> | ||||
|             </div> | ||||
|           </div> | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import { AfterViewInit, ChangeDetectionStrategy, Component, HostListener, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; | ||||
| import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, HostListener, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; | ||||
| import { combineLatest, merge, Observable, of, Subject, Subscription } from 'rxjs'; | ||||
| import { catchError, filter, map, scan, share, shareReplay, startWith, switchMap, tap } from 'rxjs/operators'; | ||||
| import { BlockExtended, OptimizedMempoolStats, TransactionStripped } from '../../interfaces/node-api.interface'; | ||||
| @ -85,6 +85,7 @@ export class CustomDashboardComponent implements OnInit, OnDestroy, AfterViewIni | ||||
|     private electrsApiService: ElectrsApiService, | ||||
|     private websocketService: WebsocketService, | ||||
|     private seoService: SeoService, | ||||
|     private cd: ChangeDetectorRef, | ||||
|     @Inject(PLATFORM_ID) private platformId: Object, | ||||
|   ) { | ||||
|     this.webGlEnabled = this.stateService.isBrowser && detectWebGL(); | ||||
| @ -283,8 +284,8 @@ export class CustomDashboardComponent implements OnInit, OnDestroy, AfterViewIni | ||||
| 
 | ||||
|   startAddressSubscription(): void { | ||||
|     if (this.stateService.env.customize && this.stateService.env.customize.dashboard.widgets.some(w => w.props?.address)) { | ||||
|       const address = this.stateService.env.customize.dashboard.widgets.find(w => w.props?.address).props.address; | ||||
|       const addressString = (/^[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100}|04[a-fA-F0-9]{128}|(02|03)[a-fA-F0-9]{64}$/.test(address)) ? address.toLowerCase() : address; | ||||
|       let addressString = this.stateService.env.customize.dashboard.widgets.find(w => w.props?.address).props.address; | ||||
|       addressString = (/^[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100}|04[a-fA-F0-9]{128}|(02|03)[a-fA-F0-9]{64}$/.test(addressString)) ? addressString.toLowerCase() : addressString; | ||||
|        | ||||
|       this.addressSubscription = ( | ||||
|         addressString.match(/04[a-fA-F0-9]{128}|(02|03)[a-fA-F0-9]{64}/) | ||||
| @ -299,6 +300,7 @@ export class CustomDashboardComponent implements OnInit, OnDestroy, AfterViewIni | ||||
|         ).subscribe((address: Address) => { | ||||
|           this.websocketService.startTrackAddress(address.address); | ||||
|           this.address = address; | ||||
|           this.cd.markForCheck(); | ||||
|         }); | ||||
| 
 | ||||
|       this.addressSummary$ = ( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user