fix infinite change loop

This commit is contained in:
Joel Wetzell
2026-05-06 16:53:40 -05:00
parent c3a0df7ca8
commit 67c4df49a8
3 changed files with 43 additions and 19 deletions
+2 -18
View File
@@ -80,15 +80,7 @@ export class App {
console.error('modules is undefined, not updating');
return;
}
this.configService.currentlyShownConfig.update((config) => {
if (config) {
return {
...config,
modules: modules,
};
}
return config;
});
this.configService.updateModules(modules);
}
routesUpdated(routes: RouteConfig[] | undefined) {
@@ -96,14 +88,6 @@ export class App {
console.error('routes is undefined, not updating');
return;
}
this.configService.currentlyShownConfig.update((config) => {
if (config) {
return {
...config,
routes: routes,
};
}
return config;
});
this.configService.updateRoutes(routes);
}
}
@@ -7,7 +7,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatTabsModule } from '@angular/material/tabs';
import { MatTooltipModule } from '@angular/material/tooltip';
import { SomeJSONSchema } from 'ajv/dist/types/json-schema';
import { cloneDeep, has } from 'lodash-es';
import { cloneDeep, has, isEqual } from 'lodash-es';
import { Subscription } from 'rxjs';
import { ParamInfo, ParamsFormInfo } from '../../models/form';
import { cleanParams, schemaToParamsFormInfo } from '../../utils/params';
@@ -103,6 +103,10 @@ export class ParamsFormComponent implements OnDestroy {
const paramsSchema = this.paramsSchema();
if (paramsSchema) {
const params = cleanParams(paramsSchema, this.paramsFormInfo?.formGroup.value);
if (isEqual(params, this.data())) {
// NOTE(jwetzell): no update
return;
}
this.updated.emit(params);
} else {
console.error('params-form: no paramsSchema loaded');
+36
View File
@@ -117,6 +117,42 @@ export class ConfigService {
}
updateCurrentlyShownConfig(config: Config) {
if (isEqual(config, this.currentlyShownConfig())) {
// NOTE(jwetzell): no update
return;
}
this.currentlyShownConfig.set(cloneDeep(config));
}
updateModules(modules: ModuleConfig[]) {
const currentConfig = this.currentlyShownConfig();
if (!currentConfig) {
console.error('No currently shown config to update modules on');
return;
}
if (isEqual(modules, currentConfig.modules)) {
return;
}
this.currentlyShownConfig.set({
...currentConfig,
modules: modules,
});
}
updateRoutes(routes: RouteConfig[]) {
const currentConfig = this.currentlyShownConfig();
if (!currentConfig) {
console.error('No currently shown config to update routes on');
return;
}
if (isEqual(routes, currentConfig.routes)) {
return;
}
this.currentlyShownConfig.set({
...currentConfig,
routes: routes,
});
}
}