From 854222b8cca18f18922f13d4b5295bd6b0208617 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sat, 6 Apr 2024 12:27:43 +0900 Subject: [PATCH] [accelerator] clear state after loading preview --- .../accelerate-preview.component.html | 2 +- .../accelerate-preview.component.ts | 16 +++++++++++----- frontend/src/app/services/state.service.ts | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html index cdbdb4a4d..3c8571dd4 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html @@ -237,7 +237,7 @@ -
+
Accelerate with
diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts index 2a958ad28..aee0189aa 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -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'); diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 010ca6b09..6d99d278a 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -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 || {};