dataflux 1.18.10 → 1.19.0

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/dist/BasicObj.js CHANGED
@@ -54,13 +54,28 @@ function setValues(values, model, SubObj, parent, context) {
54
54
  var mmnt = (0, _moment["default"])(value);
55
55
  context[key] = mmnt.isValid() ? mmnt : value;
56
56
  } else if (model.options.deep && value != null && _typeof(value) === "object" && !Array.isArray(value)) {
57
- context[key] = new SubObj(parent, key, value, model);
57
+ if (context[key] && _typeof(context[key]) === "object") {
58
+ setValues(value, model, SubObj, parent, context[key]);
59
+ } else {
60
+ context[key] = new SubObj(parent, key, value, model);
61
+ }
58
62
  } else if (model.options.deep && value != null && Array.isArray(value) && !value.some(function (str) {
59
63
  return ["string", "number"].includes(_typeof(str));
60
64
  })) {
61
- context[key] = value.map(function (i) {
62
- return new SubObj(parent, key, i, model);
65
+ var out = [];
66
+ value.forEach(function (item, order) {
67
+ var _context$key;
68
+ var old = (_context$key = context[key]) === null || _context$key === void 0 ? void 0 : _context$key.find(function (i) {
69
+ return i.id === (item === null || item === void 0 ? void 0 : item.id);
70
+ });
71
+ if (old && old.id && _typeof(old) === "object") {
72
+ setValues(item, model, SubObj, parent, old);
73
+ out.push(old);
74
+ } else {
75
+ out.push(new SubObj(parent, key, item, model));
76
+ }
63
77
  });
78
+ context[key] = out;
64
79
  } else {
65
80
  context[key] = value;
66
81
  }
package/dist/Model.js CHANGED
@@ -343,7 +343,7 @@ var Model = exports["default"] = /*#__PURE__*/_createClass(function Model(name)
343
343
  _classPrivateFieldInitSpec(this, _assignId, function (data, objects) {
344
344
  if (Array.isArray(data) && Array.isArray(objects) && objects.length === data.length) {
345
345
  for (var i = 0; i < data.length; i++) {
346
- (0, _BasicObj.setValues)(data[i], _this, _SubObj["default"], null, objects[i]);
346
+ (0, _BasicObj.setValues)(data[i], _this, _SubObj["default"], objects[i], objects[i]);
347
347
  objects[i].setId(data[i].id);
348
348
  delete objects[i].setId;
349
349
  }
@@ -61,22 +61,25 @@ var ReactStore = exports["default"] = /*#__PURE__*/function (_ObserverStore) {
61
61
  _classCallCheck(this, ReactStore);
62
62
  _this = _callSuper(this, ReactStore, [options]);
63
63
  _classPrivateMethodInitSpec(_this, _ReactStore_brand);
64
- _defineProperty(_this, "didUpdate", function (context, who) {
64
+ _defineProperty(_this, "syncState", function (object, key, context) {
65
+ if (object !== null && object !== void 0 && object.getParent) {
66
+ _this.findOne(object.getParent().getModel().getType(), key, context, function (n) {
67
+ return object.getParent().getId() === n.getId();
68
+ });
69
+ } else {
70
+ _this.findOne(object.getModel().getType(), key, context, function (n) {
71
+ return object.getId() === n.getId();
72
+ });
73
+ }
74
+ });
75
+ _defineProperty(_this, "didUpdate", function (context) {
65
76
  var _context$props;
66
77
  var objects = Object.values((_context$props = context === null || context === void 0 ? void 0 : context.props) !== null && _context$props !== void 0 ? _context$props : {}).filter(function (i) {
67
78
  var _i$isDataflux;
68
79
  return i === null || i === void 0 || (_i$isDataflux = i.isDataflux) === null || _i$isDataflux === void 0 ? void 0 : _i$isDataflux.call(i);
69
80
  });
70
81
  objects.forEach(function (object) {
71
- if (object !== null && object !== void 0 && object.getParent) {
72
- _this.findOne(object.getParent().getModel().getType(), (0, _uuid.v4)(), context, function (n) {
73
- return object.getParent().getId() === n.getId();
74
- });
75
- } else {
76
- _this.findOne(object.getModel().getType(), (0, _uuid.v4)(), context, function (n) {
77
- return object.getId() === n.getId();
78
- });
79
- }
82
+ return _this.syncState(object, (0, _uuid.v4)(), context);
80
83
  });
81
84
  });
82
85
  _classPrivateFieldInitSpec(_this, _addSubscriptionToContext, function (context, subKey) {