@onehat/data 1.22.4 → 1.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.22.4",
3
+ "version": "1.22.5",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -186,26 +186,31 @@ class TreeRepository extends OneBuildRepository {
186
186
  this.throwError(message);
187
187
  return;
188
188
  }
189
+
189
190
 
190
191
  // Set the current entities
191
- const oThis = this;
192
- const children = _.map(root, (data) => {
193
- const entity = Repository._createEntity(oThis.schema, data, this, true);
194
- oThis._relayEntityEvents(entity);
195
- return entity;
192
+ const children = [];
193
+ _.each(root, (data) => {
194
+ if (data.id === treeNode.id) {
195
+ // This is the node we're loading, so update it directly
196
+ treeNode.loadOriginalData(data);
197
+ return null;
198
+ }
199
+ const entity = Repository._createEntity(this.schema, data, this, true);
200
+ this._relayEntityEvents(entity);
201
+ children.push(entity);
196
202
  });
197
-
198
- this.entities = this.entities.concat(children);
199
-
200
- this.assembleTreeNodes();
201
-
202
- this._setPaginationVars();
203
+ if (children.length) {
204
+ this.entities = this.entities.concat(children);
205
+ this.assembleTreeNodes();
206
+ this._setPaginationVars();
207
+ }
203
208
 
204
209
  this.rehash();
205
210
  // this.emit('changeData', this.entities);
206
211
  this.emit('load', this);
207
212
 
208
- return children;
213
+ return treeNode;
209
214
  })
210
215
  .finally(() => {
211
216
  this.markLoading(false);