[accelerator] show payment preview when not logged in

This commit is contained in:
nymkappa 2023-08-26 15:07:05 +02:00
parent c0308fbc0d
commit a3d61fa525
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
3 changed files with 16 additions and 13 deletions

View File

@ -219,7 +219,7 @@
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3" *ngIf="isLoggedIn()">
<div class="col"> <div class="col">
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button class="btn btn-sm btn-primary btn-success" style="width: 150px" (click)="accelerate()">Accelerate</button> <button class="btn btn-sm btn-primary btn-success" style="width: 150px" (click)="accelerate()">Accelerate</button>

View File

@ -1,6 +1,7 @@
import { Component, OnInit, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core'; import { Component, OnInit, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
import { ApiService } from '../../services/api.service'; import { ApiService } from '../../services/api.service';
import { Subscription, catchError, of, tap } from 'rxjs'; import { Subscription, catchError, of, tap } from 'rxjs';
import { StorageService } from '../../services/storage.service';
export type AccelerationEstimate = { export type AccelerationEstimate = {
txSummary: TxSummary; txSummary: TxSummary;
@ -47,7 +48,8 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
selectFeeRateIndex = 2; selectFeeRateIndex = 2;
constructor( constructor(
private apiService: ApiService private apiService: ApiService,
private storageService: StorageService
) { } ) { }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -79,8 +81,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
} }
if (this.estimate.userBalance <= 0) { if (this.estimate.userBalance <= 0) {
this.error = `not_enough_balance`; if (this.isLoggedIn()) {
this.scrollToPreviewWithTimeout('mempoolError', 'center'); this.error = `not_enough_balance`;
this.scrollToPreviewWithTimeout('mempoolError', 'center');
}
} }
// Make min extra fee at least 50% of the current tx fee // 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;
}
} }

View File

@ -357,9 +357,7 @@ export class ApiService {
return of(null); return of(null);
} }
return this.httpClient.get<MenuGroup[]>(`${SERVICES_API_PREFIX}/account/menu`, { return this.httpClient.get<MenuGroup[]>(`${SERVICES_API_PREFIX}/account/menu`);
headers: { 'Authorization': auth.token }
});
} }
getUserInfo$(): Observable<any> { getUserInfo$(): Observable<any> {
@ -368,9 +366,7 @@ export class ApiService {
return of(null); return of(null);
} }
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/account`, { return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/account`);
headers: { 'Authorization': auth.token }
});
} }
logout$(): Observable<any> { logout$(): Observable<any> {
@ -380,9 +376,7 @@ export class ApiService {
} }
localStorage.removeItem('auth'); localStorage.removeItem('auth');
return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, { return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, {});
headers: { 'Authorization': auth.token }
});
} }
getServicesBackendInfo$(): Observable<IBackendInfo> { getServicesBackendInfo$(): Observable<IBackendInfo> {