Skip to content

Commit

Permalink
Called reload when selecting dive in tanks, options and depths
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Pokorny committed Dec 3, 2023
1 parent f68eec8 commit c801846
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions projects/planner/src/app/altitude/altitude.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class AltitudeComponent implements OnInit {
@Input()
public altitudeForm!: FormGroup;

// TODO move to unit defaults
private metricLevels = [0, 300, 800, 1500];
private imperialLevels = [0, 1000, 2600, 5000];

Expand Down
12 changes: 8 additions & 4 deletions projects/planner/src/app/diveoptions/diveoptions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
return this.inputs.controlInValid(ascentSpeed50perc);
}

// TODO fix property binding when changing selected dive
public get options(): OptionsService {
return this.schedules.selectedOptions;
}
Expand All @@ -123,7 +124,10 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
});

this.dispatcher.optionsReloaded$.pipe(takeUntil(this.unsubscribe$))
.subscribe(() => this.reloadForm());
.subscribe(() => this.reload());

this.dispatcher.selectedChanged$.pipe(takeUntil(this.unsubscribe$))
.subscribe(() => this.reload());
}

// public reset(): void {
Expand Down Expand Up @@ -168,13 +172,13 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
public useRecreational(): void {
this.options.useRecreational();
this.fireChanged();
this.reloadForm();
this.reload();
}

public useRecommended(): void {
this.options.useRecommended();
this.fireChanged();
this.reloadForm();
this.reload();
}

public switchStopsRounding(): void {
Expand Down Expand Up @@ -240,7 +244,7 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
this.dispatcher.sendOptionsChanged();
}

private reloadForm(): void {
private reload(): void {
this.optionsForm.patchValue({
maxEND: Precision.round(this.options.maxEND, 1),
problem: Precision.round(this.options.problemSolvingDuration, 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class TanksComplexComponent extends Streamed implements OnInit {

this.dispatcher.tanksReloaded$.pipe(takeUntil(this.unsubscribe$))
.subscribe(() => this.reloadAll());

this.dispatcher.selectedChanged$.pipe(takeUntil(this.unsubscribe$))
.subscribe(() => this.reloadAll());
}

public gasSac(index: number): number {
Expand Down

0 comments on commit c801846

Please sign in to comment.