diff --git a/src/editor/js/structures/manageddata.ts b/src/editor/js/structures/manageddata.ts index 65c6eeb1d540fa3567ea7c9b0ea1cde518f7f095..702dd86db8884c74145888c5110e988693366516 100644 --- a/src/editor/js/structures/manageddata.ts +++ b/src/editor/js/structures/manageddata.ts @@ -16,7 +16,7 @@ export default class ManagedData extends SerializableItem { public history: SavePoint[]; // All save points of the data. public historyPosition: number; // Currently selected save point in history. Latest always at index 0. private savedHistoryId: number; // Id of save point that is considered saved. - private storingEnabled: boolean; // To internally disable saving of objects on save call. + private storingDisabled: number; // Storing is only enabled if this is 0 (or below). /** * Sets initial states. @@ -28,7 +28,7 @@ export default class ManagedData extends SerializableItem { this.history = []; // Newest state is always at 0 this.historyPosition = 0; this.savedHistoryId = 0; - this.storingEnabled = true; + this.storingDisabled = 0; } /** @@ -88,14 +88,17 @@ export default class ManagedData extends SerializableItem { * Setter to disable storing save points. */ public disableStoring() { - this.storingEnabled = false; + this.storingDisabled += 1; } /** * Setter to enable storing save points. */ public enableStoring() { - this.storingEnabled = true; + this.storingDisabled -= 1; + if (this.storingDisabled < 0) { + this.storingDisabled = 0; + } } /** @@ -217,7 +220,7 @@ export default class ManagedData extends SerializableItem { * @param relevantChanges Indicates major or minor changes. Major changes get a new id to indicate an actual changed state. Should usually be true. */ public storeCurrentData(description: string, relevantChanges = true) { - if (this.storingEnabled === false) { + if (this.storingDisabled) { return; }