@livequery/client 1.0.32 → 1.0.34
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 +8 -4
- 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;
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
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) {
|
|
@@ -77,6 +77,7 @@ class CollectionObservable extends rxjs_1.Observable {
|
|
|
77
77
|
__classPrivateFieldGet(this, _CollectionObservable_state, "f").has_more = (_c = data === null || data === void 0 ? void 0 : data.paging) === null || _c === void 0 ? void 0 : _c.has_more;
|
|
78
78
|
__classPrivateFieldSet(this, _CollectionObservable_next_cursor, (_d = data === null || data === void 0 ? void 0 : data.paging) === null || _d === void 0 ? void 0 : _d.next_cursor, "f");
|
|
79
79
|
__classPrivateFieldGet(this, _CollectionObservable_state, "f").loading = false;
|
|
80
|
+
actions.update = true;
|
|
80
81
|
}
|
|
81
82
|
// Sync
|
|
82
83
|
for (const change of (data === null || data === void 0 ? void 0 : data.changes) || []) {
|
|
@@ -132,7 +133,7 @@ class CollectionObservable extends rxjs_1.Observable {
|
|
|
132
133
|
if (index >= 0 && realtime) {
|
|
133
134
|
if (type == 'added' || type == 'modified') {
|
|
134
135
|
actions.update = true;
|
|
135
|
-
if (Object.keys(payload).some(key => ['created_at', this.collection_options.filters._order_by].includes(key))) {
|
|
136
|
+
if (Object.keys(payload).some(key => { var _a, _b; return ['created_at', (_b = (_a = this.collection_options) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b._order_by].includes(key); })) {
|
|
136
137
|
actions.reindex = true;
|
|
137
138
|
}
|
|
138
139
|
__classPrivateFieldGet(this, _CollectionObservable_state, "f").items[index] = Object.assign(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _CollectionObservable_state, "f").items[index]), payload), { __adding: false, __updating: false, __removing: false });
|
|
@@ -149,8 +150,11 @@ class CollectionObservable extends rxjs_1.Observable {
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
|
-
actions.reindex
|
|
153
|
-
|
|
153
|
+
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));
|
|
155
|
+
__classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").clear();
|
|
156
|
+
__classPrivateFieldGet(this, _CollectionObservable_state, "f").items.map((item, index) => __classPrivateFieldGet(this, _CollectionObservable_IdMap, "f").set(item.id, index));
|
|
157
|
+
}
|
|
154
158
|
actions.update && __classPrivateFieldGet(this, _CollectionObservable_$state, "f").next(__classPrivateFieldGet(this, _CollectionObservable_state, "f"));
|
|
155
159
|
}
|
|
156
160
|
fetch_data(options = {}, flush = false) {
|