Skip to content
Snippets Groups Projects
Commit 2c21530e authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Implements proper multilayerd use of storage disabling

parent 9b55f554
No related branches found
No related tags found
No related merge requests found
Pipeline #56940 passed
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment