Skip to content

Commit

Permalink
Dont throw error if node not included in changes. Fix #1731
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Jun 10, 2020
1 parent 51dbb02 commit b4e8fff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/plugins/TwoPhaseCommit/StagedChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ define([
return this.changes;
};

StagedChanges.prototype.resolveCreateId = function(id) {
StagedChanges.prototype.tryResolveCreateId = function(id) {
const gmeId = this._createdGMEIds[id];
return gmeId;
};

StagedChanges.prototype.resolveCreateId = function(id) {
const gmeId = this.tryResolveCreateId(id);
assert(gmeId, `Creation id not resolved to actual id: ${id}`);

return gmeId;
Expand All @@ -71,6 +76,15 @@ define([
return this.changes[id];
};

StagedChanges.prototype.tryGetNodeEdits = function(id) {
id = CreatedNode.isCreateId(id) ? this.tryResolveCreateId(id) : id;
if (id) {
return null;
}

return this.changes[id];
};

StagedChanges.prototype.getModifiedNodeIds = function() {
return Object.keys(this.changes);
};
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/TwoPhaseCommit/TwoPhaseCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ define([
TwoPhaseCore.prototype._forAllNodeChanges = function (node, fn) {
const nodeId = this.getPath(node);
for (let i = 0; i < this.queuedChanges.length; i++) {
const changes = this.queuedChanges[i].getNodeEdits(nodeId);
const changes = this.queuedChanges[i].tryGetNodeEdits(nodeId);
if (changes) {
fn(changes);
}
Expand Down

0 comments on commit b4e8fff

Please sign in to comment.