Merge pull request #4901 from mempool/nymkappa/clear-state
[accelerator] clear state after loading preview
This commit is contained in:
		
						commit
						bff48b0a64
					
				| @ -237,7 +237,7 @@ | ||||
|         </div> | ||||
|       </div> | ||||
| 
 | ||||
|       <div class="row d-flex justify-content-end align-items-center mr-1" style="height: 48px" *ngIf="!hideCashApp"> | ||||
|       <div class="row d-flex justify-content-end align-items-center mr-1" style="height: 48px" *ngIf="!hideCashApp && paymentType === 'cashapp'"> | ||||
|         <div [style]="showSpinner ? 'opacity: 0' : 'opacity: 1'" class="p-2">Accelerate with</div> | ||||
|         <div id="cash-app-pay" style="max-width: 320px" [style]="showSpinner ? 'opacity: 0' : 'opacity: 1'"></div> | ||||
|         <div *ngIf="showSpinner" class="d-flex align-items-center"> | ||||
|  | ||||
| @ -39,7 +39,7 @@ export const MAX_BID_RATIO = 4; | ||||
|   templateUrl: 'accelerate-preview.component.html', | ||||
|   styleUrls: ['accelerate-preview.component.scss'] | ||||
| }) | ||||
| export class AcceleratePreviewComponent implements OnDestroy, OnChanges { | ||||
| export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges { | ||||
|   @Input() tx: Transaction | undefined; | ||||
|   @Input() scrollEvent: boolean; | ||||
| 
 | ||||
| @ -79,11 +79,8 @@ export class AcceleratePreviewComponent implements OnDestroy, OnChanges { | ||||
|     private audioService: AudioService, | ||||
|     private cd: ChangeDetectorRef | ||||
|   ) { | ||||
|     if (window.document.referrer === 'https://cash.app/') { | ||||
|     if (this.stateService.ref === 'https://cash.app/') { | ||||
|       this.insertSquare(); | ||||
|       this.paymentType = 'cashapp'; | ||||
|     } else { | ||||
|       this.paymentType = 'bitcoin'; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| @ -96,6 +93,15 @@ export class AcceleratePreviewComponent implements OnDestroy, OnChanges { | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   ngOnInit() { | ||||
|     if (this.stateService.ref === 'https://cash.app/') { | ||||
|       this.paymentType = 'cashapp'; | ||||
|       this.stateService.ref = ''; | ||||
|     } else { | ||||
|       this.paymentType = 'bitcoin'; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   ngOnChanges(changes: SimpleChanges): void { | ||||
|     if (changes.scrollEvent) { | ||||
|       this.scrollToPreview('acceleratePreviewAnchor', 'start'); | ||||
|  | ||||
| @ -86,6 +86,7 @@ const defaultEnv: Env = { | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class StateService { | ||||
|   ref: string = ''; | ||||
|   isBrowser: boolean = isPlatformBrowser(this.platformId); | ||||
|   isMempoolSpaceBuild = window['isMempoolSpaceBuild'] ?? false; | ||||
|   backend: 'esplora' | 'electrum' | 'none' = 'esplora'; | ||||
| @ -162,6 +163,8 @@ export class StateService { | ||||
|     private router: Router, | ||||
|     private storageService: StorageService, | ||||
|   ) { | ||||
|     this.ref = window.document.referrer; | ||||
| 
 | ||||
|     const browserWindow = window || {}; | ||||
|     // @ts-ignore
 | ||||
|     const browserWindowEnv = browserWindow.__env || {}; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user