From 0bc8dc7f09d969fd203bbe68b4bb1ed8ab44f901 Mon Sep 17 00:00:00 2001 From: Nazar Usov Date: Fri, 12 Apr 2024 14:51:27 +0300 Subject: [PATCH] Update get options --- html_source/src/app/app.component.ts | 2 +- html_source/src/app/pages/settings/settings.component.ts | 2 ++ .../disable-price-fetch/disable-price-fetch.directive.ts | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/html_source/src/app/app.component.ts b/html_source/src/app/app.component.ts index 657e75cd..36df645d 100644 --- a/html_source/src/app/app.component.ts +++ b/html_source/src/app/app.component.ts @@ -113,7 +113,6 @@ export class AppComponent implements OnInit, OnDestroy { this.backendService.initService().subscribe({ next: initMessage => { console.log('Init message: ', initMessage); - this.backendService.getOptions(); this.backendService.webkitLaunchedScript(); this.backendService.start_backend(false, '127.0.0.1', 11512, (st2, dd2) => { @@ -722,6 +721,7 @@ export class AppComponent implements OnInit, OnDestroy { this.getVersion(); setTimeout(() => { + this.backendService.getOptions(); this.getInfo(); }, 10 * 1000); }, diff --git a/html_source/src/app/pages/settings/settings.component.ts b/html_source/src/app/pages/settings/settings.component.ts index 892a3e69..7620ea08 100644 --- a/html_source/src/app/pages/settings/settings.component.ts +++ b/html_source/src/app/pages/settings/settings.component.ts @@ -422,6 +422,8 @@ export class SettingsComponent implements OnInit { this.scale = this.variablesService.settings.scale; this.appUseTor = this.variablesService.settings.appUseTor; this.zanoCompanionForm.setValue(this.variablesService.settings.zanoCompanionForm, { emitEvent: false }); + + this.backend.getOptions(); } ngOnInit(): void { diff --git a/html_source/src/app/parts/directives/disable-price-fetch/disable-price-fetch.directive.ts b/html_source/src/app/parts/directives/disable-price-fetch/disable-price-fetch.directive.ts index 0cabccfc..ef7f1de5 100644 --- a/html_source/src/app/parts/directives/disable-price-fetch/disable-price-fetch.directive.ts +++ b/html_source/src/app/parts/directives/disable-price-fetch/disable-price-fetch.directive.ts @@ -1,7 +1,7 @@ import { Directive, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core'; import { VariablesService } from '../../services/variables.service'; import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { distinctUntilChanged, takeUntil } from 'rxjs/operators'; @Directive({ selector: '[appDisablePriceFetch]', @@ -14,9 +14,12 @@ export class DisablePriceFetchDirective implements OnDestroy { private _templateRef: TemplateRef, private _viewContainer: ViewContainerRef ) { - this._variablesService.disable_price_fetch$.pipe(takeUntil(this.destroy$)).subscribe({ + this._variablesService.disable_price_fetch$.pipe(distinctUntilChanged(), takeUntil(this.destroy$)).subscribe({ next: (disable_price_fetch: boolean) => { - return !disable_price_fetch ? this._viewContainer.createEmbeddedView(this._templateRef) : this._viewContainer.clear(); + this._viewContainer.clear(); + if (!disable_price_fetch) { + this._viewContainer.createEmbeddedView(this._templateRef); + } }, }); }