diff --git a/packages/server/src/common/command/recording-command.ts b/packages/server/src/common/command/recording-command.ts index 4fecee7..c8e4bb6 100644 --- a/packages/server/src/common/command/recording-command.ts +++ b/packages/server/src/common/command/recording-command.ts @@ -33,7 +33,7 @@ export abstract class AbstractRecordingCommand imp const afterState = await this.getJsonObject(); this.undoPatch = jsonPatch.compare(afterState, beforeState); this.redoPatch = jsonPatch.compare(beforeState, afterState); - this.postChange?.(afterState); + await this.postChange?.(afterState); } /** @@ -65,14 +65,14 @@ export abstract class AbstractRecordingCommand imp async undo(): Promise { if (this.undoPatch) { const result = this.applyPatch(await this.getJsonObject(), this.undoPatch); - this.postChange?.(result.newDocument); + await this.postChange?.(result.newDocument); } } async redo(): Promise { if (this.redoPatch) { const result = this.applyPatch(await this.getJsonObject(), this.redoPatch); - this.postChange?.(result.newDocument); + await this.postChange?.(result.newDocument); } } diff --git a/packages/server/src/common/operations/json-operation-handler.ts b/packages/server/src/common/operations/json-operation-handler.ts index 0bd5079..44e1560 100644 --- a/packages/server/src/common/operations/json-operation-handler.ts +++ b/packages/server/src/common/operations/json-operation-handler.ts @@ -38,8 +38,8 @@ import { OperationHandler } from './operation-handler'; * Has to be implemented in order to reuse the {@link JsonOperationHandler} API. */ export interface JsonModelState extends ModelState { - readonly sourceModel: JsonObject; - updateSourceModel(sourceModel: JsonObject): void; + readonly sourceModel: MaybePromise; + updateSourceModel(sourceModel: JsonObject): MaybePromise; } export namespace JsonModelState { @@ -62,7 +62,7 @@ export class JsonRecordingCommand exte } protected override postChange(newModel: JsonObject): MaybePromise { - this.modelState.updateSourceModel(newModel); + return this.modelState.updateSourceModel(newModel); } }