diff --git a/src/app/components/module-list/module-list.ts b/src/app/components/module-list/module-list.ts index 7038726..5ec38e2 100644 --- a/src/app/components/module-list/module-list.ts +++ b/src/app/components/module-list/module-list.ts @@ -7,9 +7,9 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { MatTooltipModule } from '@angular/material/tooltip'; import { cloneDeep } from 'lodash-es'; import { ModuleConfig } from '../../models/config'; +import { ListsService } from '../../services/lists'; import { SchemaService } from '../../services/schema'; import { ModuleComponent } from '../module/module'; -import { ListsService } from '../../services/lists'; @Component({ selector: 'app-module-list', @@ -75,7 +75,6 @@ export class ModuleListComponent { } drop(event: CdkDragDrop) { - console.log('Drop event:', event); if (event.previousContainer === event.container) { const currentModules = this.modules(); if (currentModules === undefined) { diff --git a/src/app/components/route-list/route-list.ts b/src/app/components/route-list/route-list.ts index 53014b3..ccbfa4f 100644 --- a/src/app/components/route-list/route-list.ts +++ b/src/app/components/route-list/route-list.ts @@ -14,9 +14,9 @@ import { MatSnackBar } from '@angular/material/snack-bar'; import { MatTooltipModule } from '@angular/material/tooltip'; import { cloneDeep } from 'lodash-es'; import { RouteConfig } from '../../models/config'; +import { ListsService } from '../../services/lists'; import { SchemaService } from '../../services/schema'; import { RouteComponent } from '../route/route'; -import { ListsService } from '../../services/lists'; @Component({ selector: 'app-route-list', @@ -123,7 +123,6 @@ export class RouteListComponent { } drop(event: CdkDragDrop) { - console.log('Drop event:', event); if (event.previousContainer === event.container) { const currentRoutes = this.routes(); if (currentRoutes === undefined) { diff --git a/src/app/services/config.ts b/src/app/services/config.ts index 511cb6f..1587017 100644 --- a/src/app/services/config.ts +++ b/src/app/services/config.ts @@ -17,17 +17,18 @@ import { SettingsService } from './settings'; }) export class ConfigService { pendingConfigIsValid = computed(() => { - const config = this.currentlyShownConfig(); + const config = this._currentlyShownConfig(); if (config === undefined) { return false; } return this.schemaService.validate(this.schemaService.configSchemaId, config); }); - currentlyShownConfig = signal(undefined); - runningConfig = signal(undefined); + private runningConfig = signal(undefined); + private _currentlyShownConfig = signal(undefined); + readonly currentlyShownConfig = this._currentlyShownConfig.asReadonly(); configIsDirty = computed(() => { - const currentlyShown = this.currentlyShownConfig(); + const currentlyShown = this._currentlyShownConfig(); const running = this.runningConfig(); if (currentlyShown === undefined || running === undefined) { return false; @@ -44,7 +45,7 @@ export class ConfigService { constructor(private schemaService: SchemaService) { effect(() => { - console.log('config state changed', this.currentlyShownConfig()); + console.log('config state changed', this._currentlyShownConfig()); }); effect(() => { @@ -124,27 +125,22 @@ export class ConfigService { } updateCurrentlyShownConfig(config: Config) { - if (isEqual(config, this.currentlyShownConfig())) { - // NOTE(jwetzell): no update - return; - } - this.currentlyShownConfig.set(cloneDeep(config)); + this._currentlyShownConfig.set(cloneDeep(config)); } updateModules(modules: ModuleConfig[]) { - const currentConfig = this.currentlyShownConfig(); - if (!currentConfig) { + var newConfig = cloneDeep(this._currentlyShownConfig()); + if (!newConfig) { console.error('No currently shown config to update modules on'); return; } + newConfig.modules = cloneDeep(modules); - currentConfig.modules = cloneDeep(modules); - - this.updateCurrentlyShownConfig(currentConfig); + this.updateCurrentlyShownConfig(newConfig); } updateRoutes(routes: RouteConfig[]) { - const currentConfig = this.currentlyShownConfig(); + const currentConfig = this._currentlyShownConfig(); if (!currentConfig) { console.error('No currently shown config to update routes on'); return;