@amityco/ts-sdk 6.7.3-cbeeb97.0 → 6.7.3-cf5eee7.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,13 +13109,15 @@ const getMessages = (params, callback, config) => {
13099
13109
  error: data.error,
13100
13110
  });
13101
13111
  };
13102
- const realtimeRouter = (_) => (message) => {
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])];
13117
+ if (!['onFetched', 'onUpdate'].includes(action)) {
13118
+ if (!collection.data.includes(message.messageId)) {
13119
+ collection.data = [...new Set([message.messageId, ...collection.data])];
13120
+ }
13109
13121
  }
13110
13122
  pushToCache(cacheKey, collection);
13111
13123
  responder(collection);
@@ -13131,7 +13143,7 @@ const getMessages = (params, callback, config) => {
13131
13143
  responder(data);
13132
13144
  }, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
13133
13145
  };
13134
- disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(realtimeRouter()), convertEventPayload(onMessageMarked, 'contentId', 'message')(realtimeRouter()));
13146
+ disposers.push(onMessageFetched(realtimeRouter('onFetch')), onMessageCreated(realtimeRouter('onCreate')), onMessageUpdated(realtimeRouter('onUpdate')), onMessageDeleted(realtimeRouter('onDelete')), onMessageFlagged(realtimeRouter('onFlagged')), onMessageUnflagged(realtimeRouter('onUnflagged')), onMessageFlagCleared(realtimeRouter('onFlagCleared')), onMessageReactionAdded(realtimeRouter('onReactionAdded')), onMessageReactionRemoved(realtimeRouter('onReactionRemoved')), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(realtimeRouter('onUpdate')), convertEventPayload(onMessageMarked, 'contentId', 'message')(realtimeRouter('onUpdate')));
13135
13147
  onFetch(true);
13136
13148
  disposers.push(() => dropFromCache(cacheKey));
13137
13149
  return () => {
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,13 +29200,15 @@ const getMessages = (params, callback, config) => {
29190
29200
  error: data.error,
29191
29201
  });
29192
29202
  };
29193
- const realtimeRouter = (_) => (message) => {
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])];
29208
+ if (!['onFetched', 'onUpdate'].includes(action)) {
29209
+ if (!collection.data.includes(message.messageId)) {
29210
+ collection.data = [...new Set([message.messageId, ...collection.data])];
29211
+ }
29200
29212
  }
29201
29213
  pushToCache(cacheKey, collection);
29202
29214
  responder(collection);
@@ -29222,7 +29234,7 @@ const getMessages = (params, callback, config) => {
29222
29234
  responder(data);
29223
29235
  }, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
29224
29236
  };
29225
- disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(realtimeRouter()), convertEventPayload(onMessageMarked, 'contentId', 'message')(realtimeRouter()));
29237
+ disposers.push(onMessageFetched(realtimeRouter('onFetch')), onMessageCreated(realtimeRouter('onCreate')), onMessageUpdated(realtimeRouter('onUpdate')), onMessageDeleted(realtimeRouter('onDelete')), onMessageFlagged(realtimeRouter('onFlagged')), onMessageUnflagged(realtimeRouter('onUnflagged')), onMessageFlagCleared(realtimeRouter('onFlagCleared')), onMessageReactionAdded(realtimeRouter('onReactionAdded')), onMessageReactionRemoved(realtimeRouter('onReactionRemoved')), convertEventPayload(onMessageMarkerFetched, 'contentId', 'message')(realtimeRouter('onUpdate')), convertEventPayload(onMessageMarked, 'contentId', 'message')(realtimeRouter('onUpdate')));
29226
29238
  onFetch(true);
29227
29239
  disposers.push(() => dropFromCache(cacheKey));
29228
29240
  return () => {