Skip to content

Commit

Permalink
Implemented save in case switch to complex
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Pokorny committed Dec 3, 2023
1 parent 757ceb4 commit ea5c147
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions projects/planner/src/app/diveoptions/diveoptions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NonNullableFormBuilder, FormGroup, FormControl } from '@angular/forms';
import { faCog } from '@fortawesome/free-solid-svg-icons';
import { takeUntil } from 'rxjs';
import { Salinity, Precision } from 'scuba-physics';
import { DelayedScheduleService } from '../shared/delayedSchedule.service';
import { InputControls } from '../shared/inputcontrols';
import { Strategies } from '../shared/models';
import { OptionsService } from '../shared/options.service';
Expand All @@ -12,8 +11,9 @@ import { Streamed } from '../shared/streamed';
import { RangeConstants, UnitConversion } from '../shared/UnitConversion';
import { ValidatorGroups } from '../shared/ValidatorGroups';
import { ViewSwitchService } from '../shared/viewSwitchService';
import {DiveSchedules} from '../shared/dive.schedules';
import {ReloadDispatcher} from '../shared/reloadDispatcher';
import { DiveSchedules } from '../shared/dive.schedules';
import { ReloadDispatcher } from '../shared/reloadDispatcher';
import { PreferencesStore } from '../shared/preferencesStore';

@Component({
selector: 'app-diveoptions',
Expand Down Expand Up @@ -45,6 +45,7 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
private validators: ValidatorGroups,
private viewSwitch: ViewSwitchService,
private schedules: DiveSchedules,
private preferences: PreferencesStore,
private dispatcher: ReloadDispatcher) {
super();
}
Expand Down Expand Up @@ -107,9 +108,13 @@ export class DiveOptionsComponent extends Streamed implements OnInit {
this.setAllUsable();
}

// TODO check, if switch fires save preferences and calculation
this.viewSwitch.isComplex = newValue;
// we don't need to propagate the calculation, because it is triggered by depths
this.viewSwitch.isComplex = newValue;

if(newValue) {
// no data changed, we don't need to trigger calculation
this.preferences.save();
}
}

public ngOnInit(): void {
Expand Down

0 comments on commit ea5c147

Please sign in to comment.