Skip to content

Commit

Permalink
fix showSpindl logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IDIDOS committed Dec 19, 2024
1 parent 5393538 commit 4b360dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
11 changes: 5 additions & 6 deletions src/app/core/services/spindl-ads/spindl.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import spindl from '@spindl-xyz/attribution';
import { ENVIRONMENT } from 'src/environments/environment';
import { AuthService } from '../auth/auth.service';
import { distinctUntilChanged, firstValueFrom } from 'rxjs';
import { BehaviorSubject, distinctUntilChanged, firstValueFrom, Observable } from 'rxjs';
import { HttpService } from '../http/http.service';

interface IpGeolocationResp {
Expand All @@ -27,10 +27,10 @@ export class SpindlService {

private readonly IP2LOCATION_KEY = 'D13DC4B78F655A8DD9011ECC0FCDFA7D';

private _showSpindl: boolean = false;
private _showSpindl$ = new BehaviorSubject(false);

public get showSpindl(): boolean {
return this._showSpindl;
public get showSpindl$(): Observable<boolean> {
return this._showSpindl$.asObservable();
}

constructor(
Expand Down Expand Up @@ -81,8 +81,7 @@ export class SpindlService {

public async initSpindlAds(): Promise<void> {
const isForbiddenIP = await this.isForbiddenIP();
this._showSpindl = !isForbiddenIP;

this._showSpindl$.next(!isForbiddenIP);
spindl.configure({
sdkKey: '5c8549dc-9be6-49ee-bc3f-8192870f4553',
debugMode: !ENVIRONMENT.production,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
providers: providers$ | async,
selectedForm: selectedForm$ | async,
calculationStatus: calculationStatus$ | async,
transactionState: transactionState$ | async
transactionState: transactionState$ | async,
showSpindl: showSpindl$ | async
} as state"
>
<div
Expand All @@ -27,16 +28,10 @@
></app-swap-form-page>
<app-preview-swap *ngSwitchCase="'preview'"></app-preview-swap>
<app-cn-preview-swap *ngSwitchCase="'cnPreview'"></app-cn-preview-swap>

<app-spindle-banner
*ngIf="showSpindl"
*ngIf="state.showSpindl"
[ngStyle]="{
display:
state.content === 'form' ||
state.content === 'preview' ||
state.transactionState.step === 'success'
? 'block'
: 'none'
display: state.content === 'form' ? 'block' : 'none'
}"
></app-spindle-banner>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { HeaderStore } from '@core/header/services/header.store';
import { ActionButtonService } from '@features/trade/services/action-button-service/action-button.service';
import { NotificationsService } from '@core/services/notifications/notifications.service';
import { TuiNotification } from '@taiga-ui/core';
import { TargetNetworkAddressService } from '../../services/target-network-address-service/target-network-address.service';
import { PreviewSwapService } from '../../services/preview-swap/preview-swap.service';
import { FormsTogglerService } from '../../services/forms-toggler/forms-toggler.service';
import { QueryParamsService } from '@app/core/services/query-params/query-params.service';
Expand Down Expand Up @@ -60,15 +59,14 @@ export class TradeViewContainerComponent {

public readonly transactionState$ = this.previewSwapService.transactionState$;

public readonly showSpindl = this.spindlService.showSpindl;
public readonly showSpindl$ = this.spindlService.showSpindl$;

constructor(
private readonly swapsState: SwapsStateService,
private readonly tradePageService: TradePageService,
public readonly swapFormQueryService: SwapFormQueryService,
public readonly swapFormService: SwapsFormService,
public readonly swapTokensUpdaterService: SwapTokensUpdaterService,
private readonly targetNetworkAddressService: TargetNetworkAddressService,
private readonly headerStore: HeaderStore,
private readonly previewSwapService: PreviewSwapService,
private readonly actionButtonService: ActionButtonService,
Expand Down

0 comments on commit 4b360dd

Please sign in to comment.