From b4e8fffe6d7df85a4bb2595429e626301d6cae05 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Wed, 10 Jun 2020 12:33:54 -0500 Subject: [PATCH] Dont throw error if node not included in changes. Fix #1731 --- src/plugins/TwoPhaseCommit/StagedChanges.js | 16 +++++++++++++++- src/plugins/TwoPhaseCommit/TwoPhaseCore.js | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/TwoPhaseCommit/StagedChanges.js b/src/plugins/TwoPhaseCommit/StagedChanges.js index 2da30fdf9..b6ab32dd9 100644 --- a/src/plugins/TwoPhaseCommit/StagedChanges.js +++ b/src/plugins/TwoPhaseCommit/StagedChanges.js @@ -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; @@ -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); }; diff --git a/src/plugins/TwoPhaseCommit/TwoPhaseCore.js b/src/plugins/TwoPhaseCommit/TwoPhaseCore.js index ab20f3b11..f087db520 100644 --- a/src/plugins/TwoPhaseCommit/TwoPhaseCore.js +++ b/src/plugins/TwoPhaseCommit/TwoPhaseCore.js @@ -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); }