Commit 9938d6a2 authored by Paul Herbert's avatar Paul Herbert

Moved serialDisposable to shared

parent 9eb2fe56
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormGroup, Validators, FormBuilder, AbstractControl } from '@angular/forms'; import { FormGroup, Validators, FormBuilder, AbstractControl } from '@angular/forms';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'; import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import 'rxjs/add/operator/filter';
import './monitor'; import './monitor';
import { AdvancedService } from './advanced.service'; import { AdvancedService } from './advanced.service';
import { LoadingState } from './loadingState'; import { LoadingState } from './loadingState';
import { SerialDisposable } from './serialDisposable'; import { SerialDisposable } from '../../../app/shared/classes/serialDisposable';
@Component({ @Component({
selector: 'app-advanced', selector: 'app-advanced',
...@@ -20,23 +21,23 @@ export class AdvancedComponent implements OnInit, OnDestroy { ...@@ -20,23 +21,23 @@ export class AdvancedComponent implements OnInit, OnDestroy {
private addresses: string[] = []; private addresses: string[] = [];
private resyncActioned = false; private resyncActioned = false;
constructor(private advancedService: AdvancedService, private formBuilder: FormBuilder) { constructor(readonly advancedService: AdvancedService, readonly formBuilder: FormBuilder) {
this.setResyncDates(); this.setResyncDates();
} }
public icoFormGroup: FormGroup; icoFormGroup: FormGroup;
public extPubKey = ''; extPubKey = '';
public resyncDate: NgbDateStruct; extPubKeyLoadingState = new LoadingState();
public extPubKeyLoadingState = new LoadingState(); generateAddressesLoadingState = new LoadingState();
public generateAddressesLoadingState = new LoadingState(); resyncLoadingState = new LoadingState();
public resyncLoadingState = new LoadingState(); resyncDate: NgbDateStruct;
public maxResyncDate: NgbDateStruct; maxResyncDate: NgbDateStruct;
public minResyncDate: NgbDateStruct; minResyncDate: NgbDateStruct;
public get datePickerControl(): AbstractControl { return this.icoFormGroup.get('datePickerControl'); } get datePickerControl(): AbstractControl { return this.icoFormGroup.get('datePickerControl'); }
public get addressCountControl(): AbstractControl { return this.icoFormGroup.get('addressCountControl'); } get addressCountControl(): AbstractControl { return this.icoFormGroup.get('addressCountControl'); }
public get showAddressesTick(): boolean { return this.generateAddressesLoadingState.success && get showAddressesTick(): boolean { return this.generateAddressesLoadingState.success &&
this.addresses.length && (Number(this.addressCount)===this.addresses.length); } this.addresses.length && (Number(this.addressCount)===this.addresses.length); }
public get showResyncTick(): boolean { return this.resyncLoadingState.success && this.resyncActioned; } get showResyncTick(): boolean { return this.resyncLoadingState.success && this.resyncActioned; }
ngOnInit() { ngOnInit() {
this.registerFormControls(); this.registerFormControls();
...@@ -70,13 +71,10 @@ export class AdvancedComponent implements OnInit, OnDestroy { ...@@ -70,13 +71,10 @@ export class AdvancedComponent implements OnInit, OnDestroy {
datePickerControl: [Validators.required] datePickerControl: [Validators.required]
}); });
this.addressCountControl.valueChanges.subscribe(_ => { const control = this.addressCountControl;
if (this.addressCountControl.invalid) { const changes$ = control.valueChanges;
this.addressCountControl.setValue(this.addressCount); changes$.filter(_ => control.invalid).subscribe(_ => control.setValue(this.addressCount));
} else { changes$.filter(_ => !control.invalid).subscribe(_ => this.addressCount = control.value);
this.addressCount = this.addressCountControl.value;
}
});
} }
private setResyncDates() { private setResyncDates() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment