Skip to content

Commit 3b1c85d

Browse files
committed
Fix issues when restoring from saved backup
(re: #1489) Our `load` function was not working correctly, by considering the base state instead of the previous state when calling `updateCalculated` to fix caches. This changes the `load` function to do basically the same thing as the `replace`/`revert` functions that get called during the normal course of editing.
1 parent 513589b commit 3b1c85d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

modules/core/lib/Graph.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class Graph {
451451

452452
/**
453453
* revert
454-
* Revert an Entity back to whatver state it had in the base graph
454+
* Revert an Entity back to whatever state it had in the base graph
455455
* @param entityID The entityID of the Entity to revert
456456
* @return A new Graph
457457
*/
@@ -492,18 +492,16 @@ export class Graph {
492492
* load
493493
* Loads new Entities into the local Graph, obliterating any existing Entities.
494494
* Used when restoring history or entering/leaving walkthrough.
495+
* This basically does the same thing as `replace`/`remove`, but without creating a new Graph.
495496
* @param entities `Object (entityID -> Entity)`
496497
* @return this Graph
497498
*/
498499
load(entities) {
499-
const base = this._base;
500-
const local = this._local;
501-
local.entities = new Map();
502-
503500
for (const [entityID, entity] of Object.entries(entities)) {
504-
const original = base.entities.get(entityID); // likely undefined, but may as well check
505-
local.entities.set(entityID, entity);
506-
this._updateCalculated(original, entity);
501+
const current = this.hasEntity(entityID);
502+
const replacement = entity || undefined;
503+
this._updateCalculated(current, replacement);
504+
this._local.entities.set(entityID, replacement);
507505
}
508506

509507
return this;

0 commit comments

Comments
 (0)