Change addModeledMethods and updateModeledMethods to also set methods as modified

This commit is contained in:
Robert 2024-02-22 12:17:33 +00:00
Родитель 91e59323f3
Коммит 59118f63aa
3 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -124,10 +124,7 @@ export class MethodModelingViewProvider extends AbstractWebviewViewProvider<
this.databaseItem,
msg.methodSignature,
msg.modeledMethods,
);
this.modelingStore.addModifiedMethod(
this.databaseItem,
msg.methodSignature,
true,
);
break;
}

Просмотреть файл

@ -889,11 +889,10 @@ export class ModelEditorView extends AbstractWebview<
}
private addModeledMethods(modeledMethods: Record<string, ModeledMethod[]>) {
this.modelingStore.addModeledMethods(this.databaseItem, modeledMethods);
this.modelingStore.addModifiedMethods(
this.modelingStore.addModeledMethods(
this.databaseItem,
new Set(Object.keys(modeledMethods)),
modeledMethods,
true,
);
}
@ -916,8 +915,8 @@ export class ModelEditorView extends AbstractWebview<
this.databaseItem,
signature,
methods,
true,
);
this.modelingStore.addModifiedMethod(this.databaseItem, signature);
}
private startModelEvaluation() {

Просмотреть файл

@ -214,6 +214,7 @@ export class ModelingStore extends DisposableObject {
public addModeledMethods(
dbItem: DatabaseItem,
methods: Record<string, ModeledMethod[]>,
setModified: boolean,
) {
this.changeModeledMethods(dbItem, (state) => {
const newModeledMethods = {
@ -227,6 +228,10 @@ export class ModelingStore extends DisposableObject {
};
state.modeledMethods = newModeledMethods;
});
if (setModified) {
this.addModifiedMethods(dbItem, new Set(Object.keys(methods)));
}
}
public setModeledMethods(
@ -242,12 +247,17 @@ export class ModelingStore extends DisposableObject {
dbItem: DatabaseItem,
signature: string,
modeledMethods: ModeledMethod[],
setModified: boolean,
) {
this.changeModeledMethods(dbItem, (state) => {
const newModeledMethods = { ...state.modeledMethods };
newModeledMethods[signature] = modeledMethods;
state.modeledMethods = newModeledMethods;
});
if (setModified) {
this.addModifiedMethods(dbItem, [signature]);
}
}
public addModifiedMethods(
@ -263,10 +273,6 @@ export class ModelingStore extends DisposableObject {
});
}
public addModifiedMethod(dbItem: DatabaseItem, methodSignature: string) {
this.addModifiedMethods(dbItem, [methodSignature]);
}
public removeModifiedMethods(
dbItem: DatabaseItem,
methodSignatures: string[],