@amityco/ts-sdk 6.7.3-d895ed7.0 → 6.7.3-e2bf070.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/index.cjs.js
CHANGED
|
@@ -13077,12 +13077,22 @@ const getMessages = (params, callback, config) => {
|
|
|
13077
13077
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
13078
13078
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
13079
13079
|
const disposers = [];
|
|
13080
|
-
const cacheKey = ['message', 'collection', params];
|
|
13080
|
+
const cacheKey = ['message', 'collection', params, uuid()];
|
|
13081
13081
|
const responder = (data) => {
|
|
13082
13082
|
var _a, _b;
|
|
13083
13083
|
let messages = (_a = data.data
|
|
13084
13084
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
13085
13085
|
.filter(Boolean)
|
|
13086
|
+
.filter(item => {
|
|
13087
|
+
if (!params.tags)
|
|
13088
|
+
return true;
|
|
13089
|
+
return params.tags.find(value => {
|
|
13090
|
+
var _a;
|
|
13091
|
+
if (!((_a = item.data) === null || _a === void 0 ? void 0 : _a.tags))
|
|
13092
|
+
return false;
|
|
13093
|
+
return item.data.tags.includes(value);
|
|
13094
|
+
});
|
|
13095
|
+
})
|
|
13086
13096
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
13087
13097
|
/*
|
|
13088
13098
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
@@ -13099,14 +13109,11 @@ const getMessages = (params, callback, config) => {
|
|
|
13099
13109
|
error: data.error,
|
|
13100
13110
|
});
|
|
13101
13111
|
};
|
|
13102
|
-
const realtimeRouter = (
|
|
13112
|
+
const realtimeRouter = (action) => (message) => {
|
|
13103
13113
|
var _a;
|
|
13104
13114
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
13105
13115
|
if (params.subChannelId !== (message === null || message === void 0 ? void 0 : message.subChannelId) || !collection)
|
|
13106
13116
|
return;
|
|
13107
|
-
if (!collection.data.includes(message.messageId)) {
|
|
13108
|
-
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
13109
|
-
}
|
|
13110
13117
|
pushToCache(cacheKey, collection);
|
|
13111
13118
|
responder(collection);
|
|
13112
13119
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -29168,12 +29168,22 @@ const getMessages = (params, callback, config) => {
|
|
|
29168
29168
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
29169
29169
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
29170
29170
|
const disposers = [];
|
|
29171
|
-
const cacheKey = ['message', 'collection', params];
|
|
29171
|
+
const cacheKey = ['message', 'collection', params, uuid()];
|
|
29172
29172
|
const responder = (data) => {
|
|
29173
29173
|
var _a, _b;
|
|
29174
29174
|
let messages = (_a = data.data
|
|
29175
29175
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
29176
29176
|
.filter(Boolean)
|
|
29177
|
+
.filter(item => {
|
|
29178
|
+
if (!params.tags)
|
|
29179
|
+
return true;
|
|
29180
|
+
return params.tags.find(value => {
|
|
29181
|
+
var _a;
|
|
29182
|
+
if (!((_a = item.data) === null || _a === void 0 ? void 0 : _a.tags))
|
|
29183
|
+
return false;
|
|
29184
|
+
return item.data.tags.includes(value);
|
|
29185
|
+
});
|
|
29186
|
+
})
|
|
29177
29187
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
29178
29188
|
/*
|
|
29179
29189
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
@@ -29190,14 +29200,11 @@ const getMessages = (params, callback, config) => {
|
|
|
29190
29200
|
error: data.error,
|
|
29191
29201
|
});
|
|
29192
29202
|
};
|
|
29193
|
-
const realtimeRouter = (
|
|
29203
|
+
const realtimeRouter = (action) => (message) => {
|
|
29194
29204
|
var _a;
|
|
29195
29205
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29196
29206
|
if (params.subChannelId !== (message === null || message === void 0 ? void 0 : message.subChannelId) || !collection)
|
|
29197
29207
|
return;
|
|
29198
|
-
if (!collection.data.includes(message.messageId)) {
|
|
29199
|
-
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
29200
|
-
}
|
|
29201
29208
|
pushToCache(cacheKey, collection);
|
|
29202
29209
|
responder(collection);
|
|
29203
29210
|
};
|