@livequery/client 1.0.34 → 1.0.36

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.
@@ -67,7 +67,7 @@ class CollectionObservable extends rxjs_1.Observable {
67
67
  this.document_id = this.is_collection_ref ? null : refs[refs.length - 1];
68
68
  }
69
69
  sync(stream) {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
71
71
  const realtime = (_a = this.collection_options.realtime) !== null && _a !== void 0 ? _a : true;
72
72
  const actions = { update: false, reindex: false };
73
73
  for (const { data, error } of stream) {
@@ -81,13 +81,15 @@ class CollectionObservable extends rxjs_1.Observable {
81
81
  }
82
82
  // Sync
83
83
  for (const change of (data === null || data === void 0 ? void 0 : data.changes) || []) {
84
+ if (!((_e = change === null || change === void 0 ? void 0 : change.data) === null || _e === void 0 ? void 0 : _e.id))
85
+ continue;
84
86
  const { data: payload, type } = change;
85
87
  this.$changes.next(change);
86
- const index = (_e = __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").get(payload.id)) !== null && _e !== void 0 ? _e : -1;
88
+ const index = (_f = __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").get(payload.id)) !== null && _f !== void 0 ? _f : -1;
87
89
  if (index == -1 && type == 'added') {
88
90
  if (
89
91
  // Is first value from HTTP query
90
- ((_f = data === null || data === void 0 ? void 0 : data.paging) === null || _f === void 0 ? void 0 : _f.n) == 0
92
+ ((_g = data === null || data === void 0 ? void 0 : data.paging) === null || _g === void 0 ? void 0 : _g.n) == 0
91
93
  || (
92
94
  // Is realtime update that match filters
93
95
  realtime && Object
@@ -151,7 +153,7 @@ class CollectionObservable extends rxjs_1.Observable {
151
153
  }
152
154
  }
153
155
  if (actions.reindex) {
154
- __classPrivateFieldGet(this, _CollectionObservable_state, "f").items = __classPrivateFieldGet(this, _CollectionObservable_state, "f").items.sort((0, get_sort_function_1.get_sort_function)(__classPrivateFieldGet(this, _CollectionObservable_state, "f").items[0], ((_h = (_g = this.collection_options) === null || _g === void 0 ? void 0 : _g.filters) === null || _h === void 0 ? void 0 : _h._order_by) || 'created_at', (_k = (_j = this.collection_options) === null || _j === void 0 ? void 0 : _j.filters) === null || _k === void 0 ? void 0 : _k._sort));
156
+ __classPrivateFieldGet(this, _CollectionObservable_state, "f").items = __classPrivateFieldGet(this, _CollectionObservable_state, "f").items.sort((0, get_sort_function_1.get_sort_function)(__classPrivateFieldGet(this, _CollectionObservable_state, "f").items[0], ((_j = (_h = this.collection_options) === null || _h === void 0 ? void 0 : _h.filters) === null || _j === void 0 ? void 0 : _j._order_by) || 'created_at', (_l = (_k = this.collection_options) === null || _k === void 0 ? void 0 : _k.filters) === null || _l === void 0 ? void 0 : _l._sort));
155
157
  __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").clear();
156
158
  __classPrivateFieldGet(this, _CollectionObservable_state, "f").items.map((item, index) => __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").set(item.id, index));
157
159
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "url": "https://github.com/livequery/client"
5
5
  },
6
- "version": "1.0.34",
6
+ "version": "1.0.36",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",