From a3d61fa52546b1406a8e932648c8c91b73055f5e Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sat, 26 Aug 2023 15:07:05 +0200 Subject: [PATCH] [accelerator] show payment preview when not logged in --- .../accelerate-preview.component.html | 2 +- .../accelerate-preview.component.ts | 15 ++++++++++++--- frontend/src/app/services/api.service.ts | 12 +++--------- 3 files changed, 16 insertions(+), 13 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 5afdc07f9..c546d3859 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html @@ -219,7 +219,7 @@ -
+
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 bea0efb88..b4c7af704 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core'; import { ApiService } from '../../services/api.service'; import { Subscription, catchError, of, tap } from 'rxjs'; +import { StorageService } from '../../services/storage.service'; export type AccelerationEstimate = { txSummary: TxSummary; @@ -47,7 +48,8 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges selectFeeRateIndex = 2; constructor( - private apiService: ApiService + private apiService: ApiService, + private storageService: StorageService ) { } ngOnDestroy(): void { @@ -79,8 +81,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges } if (this.estimate.userBalance <= 0) { - this.error = `not_enough_balance`; - this.scrollToPreviewWithTimeout('mempoolError', 'center'); + if (this.isLoggedIn()) { + this.error = `not_enough_balance`; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + } } // Make min extra fee at least 50% of the current tx fee @@ -166,4 +170,9 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges } }); } + + isLoggedIn() { + const auth = this.storageService.getAuth(); + return auth !== null; + } } \ No newline at end of file diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index ea185b1ec..744474f9d 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -357,9 +357,7 @@ export class ApiService { return of(null); } - return this.httpClient.get(`${SERVICES_API_PREFIX}/account/menu`, { - headers: { 'Authorization': auth.token } - }); + return this.httpClient.get(`${SERVICES_API_PREFIX}/account/menu`); } getUserInfo$(): Observable { @@ -368,9 +366,7 @@ export class ApiService { return of(null); } - return this.httpClient.get(`${SERVICES_API_PREFIX}/account`, { - headers: { 'Authorization': auth.token } - }); + return this.httpClient.get(`${SERVICES_API_PREFIX}/account`); } logout$(): Observable { @@ -380,9 +376,7 @@ export class ApiService { } localStorage.removeItem('auth'); - return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, { - headers: { 'Authorization': auth.token } - }); + return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, {}); } getServicesBackendInfo$(): Observable {