@amityco/ts-sdk 7.32.1-23b143a2.0 → 7.32.1-6d2e2c1e.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.
@@ -1 +1 @@
1
- {"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,4CAAyC,OAqBlE,CAAC"}
1
+ {"version":3,"file":"dropFromCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/dropFromCache.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,4CAAyC,OAsBlE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,8BAEhB,OAAO,YACJ,MAAM,YAAY,KAC1B,OAmBF,CAAC"}
1
+ {"version":3,"file":"pushToCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/pushToCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,8BAEhB,OAAO,YACJ,MAAM,YAAY,KAC1B,OAkBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EAWtB,CAAC"}
1
+ {"version":3,"file":"queryCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/queryCache.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,+EAatB,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -1184,116 +1184,17 @@ const wipeCache = async (storageKey = 'amitySdk') => {
1184
1184
  return true;
1185
1185
  };
1186
1186
 
1187
- // Indexes never enter persisted cache data. Replacing data (restore/wipe/enable) starts a new index.
1188
- const indexes = new WeakMap();
1189
- const prefixesFor = (key) => {
1190
- if (typeof key[0] !== 'string')
1191
- return [];
1192
- const prefixes = [JSON.stringify([key[0]])];
1193
- if (typeof key[1] === 'string')
1194
- prefixes.push(JSON.stringify([key[0], key[1]]));
1195
- return prefixes;
1196
- };
1197
- const removePropertyValue = (property, indexed) => {
1198
- const previous = property.previousValues.get(indexed.encodedKey);
1199
- if (previous === undefined)
1200
- return;
1201
- const matches = property.values.get(previous);
1202
- matches.delete(indexed);
1203
- if (!matches.size)
1204
- property.values.delete(previous);
1205
- property.previousValues.delete(indexed.encodedKey);
1206
- };
1207
- const addPropertyValue = (data, property, indexed) => {
1208
- var _a;
1209
- if (!partialMatch(property.prefix, indexed.key))
1210
- return;
1211
- const value = (_a = data[indexed.encodedKey].data) === null || _a === void 0 ? void 0 : _a[property.property];
1212
- if (typeof value !== 'string')
1213
- return;
1214
- let matches = property.values.get(value);
1215
- if (!matches) {
1216
- matches = new Set();
1217
- property.values.set(value, matches);
1218
- }
1219
- matches.add(indexed);
1220
- property.previousValues.set(indexed.encodedKey, value);
1221
- };
1222
- const addKey = (index, encodedKey) => {
1223
- const indexed = { encodedKey, key: decodeKey(encodedKey), order: index.nextOrder };
1224
- index.nextOrder += 1; // eslint-disable-line no-param-reassign
1225
- index.keys.set(encodedKey, indexed);
1226
- prefixesFor(indexed.key).forEach(prefix => {
1227
- let keys = index.prefixes.get(prefix);
1228
- if (!keys) {
1229
- keys = new Map();
1230
- index.prefixes.set(prefix, keys);
1231
- }
1232
- keys.set(encodedKey, indexed);
1233
- });
1234
- return indexed;
1235
- };
1236
- const getIndex = (data) => {
1237
- let index = indexes.get(data);
1238
- if (!index) {
1239
- index = { keys: new Map(), prefixes: new Map(), properties: new Map(), nextOrder: 0 };
1240
- Object.keys(data).forEach(encodedKey => addKey(index, encodedKey));
1241
- indexes.set(data, index);
1242
- }
1243
- return index;
1244
- };
1245
- const candidatesFor = (index, key) => {
1246
- var _a, _b;
1247
- const prefixes = prefixesFor(key);
1248
- if (!prefixes.length)
1249
- return index.keys.values();
1250
- return (_b = (_a = index.prefixes.get(prefixes[prefixes.length - 1])) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : [];
1251
- };
1252
- /** @hidden */
1253
- const getMatchingCacheKeys = (data, key) => Array.from(candidatesFor(getIndex(data), key)).filter(indexed => partialMatch(key, indexed.key));
1254
- /** Update only an index that has already been used; writes alone need no index build. @hidden */
1255
- const updateCacheIndex = (data, encodedKey) => {
1256
- var _a;
1257
- const index = indexes.get(data);
1258
- if (!index)
1259
- return;
1260
- const indexed = (_a = index.keys.get(encodedKey)) !== null && _a !== void 0 ? _a : addKey(index, encodedKey);
1261
- index.properties.forEach(property => {
1262
- removePropertyValue(property, indexed);
1263
- addPropertyValue(data, property, indexed);
1264
- });
1265
- };
1266
- /** @hidden */
1267
- const removeFromCacheIndex = (data, encodedKey) => {
1268
- const index = indexes.get(data);
1269
- const indexed = index === null || index === void 0 ? void 0 : index.keys.get(encodedKey);
1270
- if (!index || !indexed)
1271
- return;
1272
- index.properties.forEach(property => removePropertyValue(property, indexed));
1273
- prefixesFor(indexed.key).forEach(prefix => {
1274
- const keys = index.prefixes.get(prefix);
1275
- keys.delete(encodedKey);
1276
- if (!keys.size)
1277
- index.prefixes.delete(prefix);
1278
- });
1279
- index.keys.delete(encodedKey);
1280
- };
1281
- /** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
1282
- const getCacheEntriesByProperty = (data, prefix, property, value) => {
1283
- var _a;
1284
- const index = getIndex(data);
1285
- const identity = JSON.stringify([prefix, property]);
1286
- let propertyIndex = index.properties.get(identity);
1287
- if (!propertyIndex) {
1288
- propertyIndex = { prefix, property, values: new Map(), previousValues: new Map() };
1289
- index.properties.set(identity, propertyIndex);
1290
- Array.from(candidatesFor(index, prefix)).forEach(indexed => addPropertyValue(data, propertyIndex, indexed));
1187
+ const isPrimitiveKey = (key) => Array.isArray(key) &&
1188
+ key.length > 0 &&
1189
+ key.every(segment => typeof segment === 'string' || typeof segment === 'number');
1190
+ const createMatcher = (key) => {
1191
+ if (isPrimitiveKey(key)) {
1192
+ const encoded = encodeKey(key);
1193
+ const prefix = `${encoded.slice(0, -1)},`;
1194
+ return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
1291
1195
  }
1292
- return Array.from((_a = propertyIndex.values.get(value)) !== null && _a !== void 0 ? _a : [])
1293
- .sort((a, b) => a.order - b.order)
1294
- .map(({ encodedKey }) => data[encodedKey]);
1196
+ return encodedKey => partialMatch(key, decodeKey(encodedKey));
1295
1197
  };
1296
-
1297
1198
  /**
1298
1199
  * ```js
1299
1200
  * import { queryCache } from '@amityco/ts-sdk'
@@ -1314,7 +1215,10 @@ const queryCache = (key) => {
1314
1215
  if (!cache)
1315
1216
  return;
1316
1217
  log('cache/api/queryCache', { key });
1317
- return getMatchingCacheKeys(cache.data, key).map(({ encodedKey }) => cache.data[encodedKey]);
1218
+ const matches = createMatcher(key);
1219
+ return Object.keys(cache.data)
1220
+ .filter(matches)
1221
+ .map(stringKey => cache.data[stringKey]);
1318
1222
  };
1319
1223
 
1320
1224
  /**
@@ -1370,7 +1274,6 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
1370
1274
  }
1371
1275
  const encodedKey = encodeKey(key);
1372
1276
  cache.data[encodedKey] = Object.assign({ key, data }, options);
1373
- updateCacheIndex(cache.data, encodedKey);
1374
1277
  return true;
1375
1278
  };
1376
1279
 
@@ -1455,14 +1358,15 @@ const dropFromCache = (key, exact = false) => {
1455
1358
  return false;
1456
1359
  log('cache/api/dropFromCache', { key, exact });
1457
1360
  if (!exact) {
1458
- return getMatchingCacheKeys(cache.data, key)
1459
- .map(({ key: filteredKey }) => dropFromCache(filteredKey, true))
1361
+ return Object.keys(cache.data)
1362
+ .map(stringKey => decodeKey(stringKey))
1363
+ .filter(candidate => partialMatch(key, candidate))
1364
+ .map(filteredKey => dropFromCache(filteredKey, true))
1460
1365
  .every(returned => returned);
1461
1366
  }
1462
1367
  const encodedKey = encodeKey(key);
1463
1368
  if (encodedKey in cache.data) {
1464
1369
  delete cache.data[encodedKey];
1465
- removeFromCacheIndex(cache.data, encodedKey);
1466
1370
  return true;
1467
1371
  }
1468
1372
  return false;
@@ -3851,20 +3755,13 @@ const getUserMarker = async () => {
3851
3755
  return { data: latestUserMarker, cachedAt };
3852
3756
  };
3853
3757
 
3854
- /** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
3855
- const queryCacheByProperty = (prefix, property, value) => {
3856
- const { cache } = getActiveClient();
3857
- if (!cache)
3858
- return;
3859
- return getCacheEntriesByProperty(cache.data, prefix, property, value);
3860
- };
3861
-
3862
3758
  const getMessageFromMainDB = (messageId) => {
3863
- var _a, _b, _c;
3759
+ var _a, _b;
3864
3760
  const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
3865
3761
  if (message)
3866
3762
  return message;
3867
- return (_c = (_b = queryCacheByProperty(['message', 'get'], 'messageId', messageId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.data;
3763
+ const messages = queryCache(['message', 'get']);
3764
+ return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
3868
3765
  };
3869
3766
 
3870
3767
  /** @hidden */
@@ -4006,8 +3903,7 @@ function convertFromRaw$2(_a) {
4006
3903
 
4007
3904
  const mergePayloadWithLocal = (payload) => {
4008
3905
  var _a, _b, _c;
4009
- // Cache keys may be local referenceIds even after a server messageId is assigned.
4010
- const localMessage = (_b = (_a = queryCacheByProperty(['message', 'get'], 'messageId', payload.messageId)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
3906
+ const localMessage = (_b = (_a = queryCache(['message', 'get'])) === null || _a === void 0 ? void 0 : _a.find(({ data }) => data.messageId === payload.messageId)) === null || _b === void 0 ? void 0 : _b.data;
4011
3907
  if (localMessage) {
4012
3908
  return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
4013
3909
  // NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
@@ -5574,9 +5470,9 @@ const channelLinkedObject = (channel) => {
5574
5470
  var _a;
5575
5471
  let previewMembers = [];
5576
5472
  if (['conversation', 'community'].includes(channel.type)) {
5577
- const channelUsers = queryCacheByProperty(['channelUsers', 'get'], 'channelId', channel.channelId);
5473
+ const channelUsers = queryCache(['channelUsers', 'get']);
5578
5474
  if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
5579
- previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
5475
+ previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId && data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
5580
5476
  // sort in ascending order by userInternalId
5581
5477
  .sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
5582
5478
  // Select only first 4 members
package/dist/index.esm.js CHANGED
@@ -1168,116 +1168,17 @@ const wipeCache = async (storageKey = 'amitySdk') => {
1168
1168
  return true;
1169
1169
  };
1170
1170
 
1171
- // Indexes never enter persisted cache data. Replacing data (restore/wipe/enable) starts a new index.
1172
- const indexes = new WeakMap();
1173
- const prefixesFor = (key) => {
1174
- if (typeof key[0] !== 'string')
1175
- return [];
1176
- const prefixes = [JSON.stringify([key[0]])];
1177
- if (typeof key[1] === 'string')
1178
- prefixes.push(JSON.stringify([key[0], key[1]]));
1179
- return prefixes;
1180
- };
1181
- const removePropertyValue = (property, indexed) => {
1182
- const previous = property.previousValues.get(indexed.encodedKey);
1183
- if (previous === undefined)
1184
- return;
1185
- const matches = property.values.get(previous);
1186
- matches.delete(indexed);
1187
- if (!matches.size)
1188
- property.values.delete(previous);
1189
- property.previousValues.delete(indexed.encodedKey);
1190
- };
1191
- const addPropertyValue = (data, property, indexed) => {
1192
- var _a;
1193
- if (!partialMatch(property.prefix, indexed.key))
1194
- return;
1195
- const value = (_a = data[indexed.encodedKey].data) === null || _a === void 0 ? void 0 : _a[property.property];
1196
- if (typeof value !== 'string')
1197
- return;
1198
- let matches = property.values.get(value);
1199
- if (!matches) {
1200
- matches = new Set();
1201
- property.values.set(value, matches);
1202
- }
1203
- matches.add(indexed);
1204
- property.previousValues.set(indexed.encodedKey, value);
1205
- };
1206
- const addKey = (index, encodedKey) => {
1207
- const indexed = { encodedKey, key: decodeKey(encodedKey), order: index.nextOrder };
1208
- index.nextOrder += 1; // eslint-disable-line no-param-reassign
1209
- index.keys.set(encodedKey, indexed);
1210
- prefixesFor(indexed.key).forEach(prefix => {
1211
- let keys = index.prefixes.get(prefix);
1212
- if (!keys) {
1213
- keys = new Map();
1214
- index.prefixes.set(prefix, keys);
1215
- }
1216
- keys.set(encodedKey, indexed);
1217
- });
1218
- return indexed;
1219
- };
1220
- const getIndex = (data) => {
1221
- let index = indexes.get(data);
1222
- if (!index) {
1223
- index = { keys: new Map(), prefixes: new Map(), properties: new Map(), nextOrder: 0 };
1224
- Object.keys(data).forEach(encodedKey => addKey(index, encodedKey));
1225
- indexes.set(data, index);
1226
- }
1227
- return index;
1228
- };
1229
- const candidatesFor = (index, key) => {
1230
- var _a, _b;
1231
- const prefixes = prefixesFor(key);
1232
- if (!prefixes.length)
1233
- return index.keys.values();
1234
- return (_b = (_a = index.prefixes.get(prefixes[prefixes.length - 1])) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : [];
1235
- };
1236
- /** @hidden */
1237
- const getMatchingCacheKeys = (data, key) => Array.from(candidatesFor(getIndex(data), key)).filter(indexed => partialMatch(key, indexed.key));
1238
- /** Update only an index that has already been used; writes alone need no index build. @hidden */
1239
- const updateCacheIndex = (data, encodedKey) => {
1240
- var _a;
1241
- const index = indexes.get(data);
1242
- if (!index)
1243
- return;
1244
- const indexed = (_a = index.keys.get(encodedKey)) !== null && _a !== void 0 ? _a : addKey(index, encodedKey);
1245
- index.properties.forEach(property => {
1246
- removePropertyValue(property, indexed);
1247
- addPropertyValue(data, property, indexed);
1248
- });
1249
- };
1250
- /** @hidden */
1251
- const removeFromCacheIndex = (data, encodedKey) => {
1252
- const index = indexes.get(data);
1253
- const indexed = index === null || index === void 0 ? void 0 : index.keys.get(encodedKey);
1254
- if (!index || !indexed)
1255
- return;
1256
- index.properties.forEach(property => removePropertyValue(property, indexed));
1257
- prefixesFor(indexed.key).forEach(prefix => {
1258
- const keys = index.prefixes.get(prefix);
1259
- keys.delete(encodedKey);
1260
- if (!keys.size)
1261
- index.prefixes.delete(prefix);
1262
- });
1263
- index.keys.delete(encodedKey);
1264
- };
1265
- /** Index a string model property within one domain/operation, retaining cache insertion order. @hidden */
1266
- const getCacheEntriesByProperty = (data, prefix, property, value) => {
1267
- var _a;
1268
- const index = getIndex(data);
1269
- const identity = JSON.stringify([prefix, property]);
1270
- let propertyIndex = index.properties.get(identity);
1271
- if (!propertyIndex) {
1272
- propertyIndex = { prefix, property, values: new Map(), previousValues: new Map() };
1273
- index.properties.set(identity, propertyIndex);
1274
- Array.from(candidatesFor(index, prefix)).forEach(indexed => addPropertyValue(data, propertyIndex, indexed));
1171
+ const isPrimitiveKey = (key) => Array.isArray(key) &&
1172
+ key.length > 0 &&
1173
+ key.every(segment => typeof segment === 'string' || typeof segment === 'number');
1174
+ const createMatcher = (key) => {
1175
+ if (isPrimitiveKey(key)) {
1176
+ const encoded = encodeKey(key);
1177
+ const prefix = `${encoded.slice(0, -1)},`;
1178
+ return encodedKey => encodedKey === encoded || encodedKey.startsWith(prefix);
1275
1179
  }
1276
- return Array.from((_a = propertyIndex.values.get(value)) !== null && _a !== void 0 ? _a : [])
1277
- .sort((a, b) => a.order - b.order)
1278
- .map(({ encodedKey }) => data[encodedKey]);
1180
+ return encodedKey => partialMatch(key, decodeKey(encodedKey));
1279
1181
  };
1280
-
1281
1182
  /**
1282
1183
  * ```js
1283
1184
  * import { queryCache } from '@amityco/ts-sdk'
@@ -1298,7 +1199,10 @@ const queryCache = (key) => {
1298
1199
  if (!cache)
1299
1200
  return;
1300
1201
  log('cache/api/queryCache', { key });
1301
- return getMatchingCacheKeys(cache.data, key).map(({ encodedKey }) => cache.data[encodedKey]);
1202
+ const matches = createMatcher(key);
1203
+ return Object.keys(cache.data)
1204
+ .filter(matches)
1205
+ .map(stringKey => cache.data[stringKey]);
1302
1206
  };
1303
1207
 
1304
1208
  /**
@@ -1354,7 +1258,6 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
1354
1258
  }
1355
1259
  const encodedKey = encodeKey(key);
1356
1260
  cache.data[encodedKey] = Object.assign({ key, data }, options);
1357
- updateCacheIndex(cache.data, encodedKey);
1358
1261
  return true;
1359
1262
  };
1360
1263
 
@@ -1439,14 +1342,15 @@ const dropFromCache = (key, exact = false) => {
1439
1342
  return false;
1440
1343
  log('cache/api/dropFromCache', { key, exact });
1441
1344
  if (!exact) {
1442
- return getMatchingCacheKeys(cache.data, key)
1443
- .map(({ key: filteredKey }) => dropFromCache(filteredKey, true))
1345
+ return Object.keys(cache.data)
1346
+ .map(stringKey => decodeKey(stringKey))
1347
+ .filter(candidate => partialMatch(key, candidate))
1348
+ .map(filteredKey => dropFromCache(filteredKey, true))
1444
1349
  .every(returned => returned);
1445
1350
  }
1446
1351
  const encodedKey = encodeKey(key);
1447
1352
  if (encodedKey in cache.data) {
1448
1353
  delete cache.data[encodedKey];
1449
- removeFromCacheIndex(cache.data, encodedKey);
1450
1354
  return true;
1451
1355
  }
1452
1356
  return false;
@@ -3851,20 +3755,13 @@ const getUserMarker = async () => {
3851
3755
  return { data: latestUserMarker, cachedAt };
3852
3756
  };
3853
3757
 
3854
- /** Internal model lookup; deliberately excluded from the public Cache API. @hidden */
3855
- const queryCacheByProperty = (prefix, property, value) => {
3856
- const { cache } = getActiveClient();
3857
- if (!cache)
3858
- return;
3859
- return getCacheEntriesByProperty(cache.data, prefix, property, value);
3860
- };
3861
-
3862
3758
  const getMessageFromMainDB = (messageId) => {
3863
- var _a, _b, _c;
3759
+ var _a, _b;
3864
3760
  const message = (_a = pullFromCache(['message', 'get', messageId])) === null || _a === void 0 ? void 0 : _a.data;
3865
3761
  if (message)
3866
3762
  return message;
3867
- return (_c = (_b = queryCacheByProperty(['message', 'get'], 'messageId', messageId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.data;
3763
+ const messages = queryCache(['message', 'get']);
3764
+ return (_b = messages === null || messages === void 0 ? void 0 : messages.find(({ data }) => data.messageId === messageId)) === null || _b === void 0 ? void 0 : _b.data;
3868
3765
  };
3869
3766
 
3870
3767
  /** @hidden */
@@ -4006,8 +3903,7 @@ function convertFromRaw$2(_a) {
4006
3903
 
4007
3904
  const mergePayloadWithLocal = (payload) => {
4008
3905
  var _a, _b, _c;
4009
- // Cache keys may be local referenceIds even after a server messageId is assigned.
4010
- const localMessage = (_b = (_a = queryCacheByProperty(['message', 'get'], 'messageId', payload.messageId)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
3906
+ const localMessage = (_b = (_a = queryCache(['message', 'get'])) === null || _a === void 0 ? void 0 : _a.find(({ data }) => data.messageId === payload.messageId)) === null || _b === void 0 ? void 0 : _b.data;
4011
3907
  if (localMessage) {
4012
3908
  return Object.assign(Object.assign(Object.assign({}, localMessage), payload), {
4013
3909
  // NOTE: referenceId is missing in the some payload event. If we have local message data with referenceId, use it instead.
@@ -5574,9 +5470,9 @@ const channelLinkedObject = (channel) => {
5574
5470
  var _a;
5575
5471
  let previewMembers = [];
5576
5472
  if (['conversation', 'community'].includes(channel.type)) {
5577
- const channelUsers = queryCacheByProperty(['channelUsers', 'get'], 'channelId', channel.channelId);
5473
+ const channelUsers = queryCache(['channelUsers', 'get']);
5578
5474
  if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
5579
- previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
5475
+ previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId && data.membership !== 'none')) !== null && _a !== void 0 ? _a : [])
5580
5476
  // sort in ascending order by userInternalId
5581
5477
  .sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
5582
5478
  // Select only first 4 members