@livequery/client 1.0.35 → 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.
- package/build/Collection.js +5 -5
- package/package.json +1 -1
package/build/Collection.js
CHANGED
|
@@ -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,15 +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 (!change.data.id)
|
|
84
|
+
if (!((_e = change === null || change === void 0 ? void 0 : change.data) === null || _e === void 0 ? void 0 : _e.id))
|
|
85
85
|
continue;
|
|
86
86
|
const { data: payload, type } = change;
|
|
87
87
|
this.$changes.next(change);
|
|
88
|
-
const index = (
|
|
88
|
+
const index = (_f = __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").get(payload.id)) !== null && _f !== void 0 ? _f : -1;
|
|
89
89
|
if (index == -1 && type == 'added') {
|
|
90
90
|
if (
|
|
91
91
|
// Is first value from HTTP query
|
|
92
|
-
((
|
|
92
|
+
((_g = data === null || data === void 0 ? void 0 : data.paging) === null || _g === void 0 ? void 0 : _g.n) == 0
|
|
93
93
|
|| (
|
|
94
94
|
// Is realtime update that match filters
|
|
95
95
|
realtime && Object
|
|
@@ -153,7 +153,7 @@ class CollectionObservable extends rxjs_1.Observable {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
if (actions.reindex) {
|
|
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], ((
|
|
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));
|
|
157
157
|
__classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").clear();
|
|
158
158
|
__classPrivateFieldGet(this, _CollectionObservable_state, "f").items.map((item, index) => __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").set(item.id, index));
|
|
159
159
|
}
|