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, this.databaseItem,
msg.methodSignature, msg.methodSignature,
msg.modeledMethods, msg.modeledMethods,
); true,
this.modelingStore.addModifiedMethod(
this.databaseItem,
msg.methodSignature,
); );
break; break;
} }

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

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

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

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