stream-chat 8.56.0 → 8.56.1

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.js CHANGED
@@ -427,8 +427,8 @@ function normalizeQuerySort(sort) {
427
427
 
428
428
  try {
429
429
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
430
- var item = _step.value;
431
- var entries = Object.entries(item);
430
+ var _item = _step.value;
431
+ var entries = Object.entries(_item);
432
432
 
433
433
  if (entries.length > 1) {
434
434
  console.warn("client._buildSort() - multiple fields in a single sort object detected. Object's field order is not guaranteed");
@@ -836,6 +836,28 @@ var throttle = function throttle(fn) {
836
836
  runningTimeout = setTimeout(timeoutHandler, timeout);
837
837
  };
838
838
  };
839
+
840
+ var get = function get(obj, path) {
841
+ return path.split('.').reduce(function (acc, key) {
842
+ if (acc && _typeof__default['default'](acc) === 'object' && key in acc) {
843
+ return acc[key];
844
+ }
845
+
846
+ return undefined;
847
+ }, obj);
848
+ }; // works exactly the same as lodash.uniqBy
849
+
850
+
851
+ var uniqBy = function uniqBy(array, iteratee) {
852
+ if (!Array.isArray(array)) return [];
853
+ var seen = new Set();
854
+ return array.filter(function (item) {
855
+ var key = typeof iteratee === 'function' ? iteratee(item) : get(item, iteratee);
856
+ if (seen.has(key)) return false;
857
+ seen.add(key);
858
+ return true;
859
+ });
860
+ };
839
861
  function binarySearchByDateEqualOrNearestGreater(array, targetDate) {
840
862
  var left = 0;
841
863
  var right = array.length - 1;
@@ -10981,13 +11003,13 @@ var ChannelManager = function ChannelManager(_ref) {
10981
11003
  }());
10982
11004
 
10983
11005
  _defineProperty__default['default'](this, "loadNext", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
10984
- var _this$state$getLatest3, pagination, channels, initialized, filters, sort, options, isLoadingNext, hasNext, _nextChannels$length, _nextChannels$length2, _DEFAULT_CHANNEL_MANA2, offset, limit, nextChannels, newOffset, newOptions;
11006
+ var _this$state$getLatest3, pagination, initialized, filters, sort, options, isLoadingNext, hasNext, _nextChannels$length, _nextChannels$length2, _DEFAULT_CHANNEL_MANA2, offset, limit, nextChannels, _this$state$getLatest4, channels, newOffset, newOptions;
10985
11007
 
10986
11008
  return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
10987
11009
  while (1) {
10988
11010
  switch (_context2.prev = _context2.next) {
10989
11011
  case 0:
10990
- _this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, channels = _this$state$getLatest3.channels, initialized = _this$state$getLatest3.initialized;
11012
+ _this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, initialized = _this$state$getLatest3.initialized;
10991
11013
  filters = pagination.filters, sort = pagination.sort, options = pagination.options, isLoadingNext = pagination.isLoadingNext, hasNext = pagination.hasNext;
10992
11014
 
10993
11015
  if (!(!initialized || isLoadingNext || !hasNext)) {
@@ -11013,13 +11035,14 @@ var ChannelManager = function ChannelManager(_ref) {
11013
11035
 
11014
11036
  case 9:
11015
11037
  nextChannels = _context2.sent;
11038
+ _this$state$getLatest4 = _this.state.getLatestValue(), channels = _this$state$getLatest4.channels;
11016
11039
  newOffset = offset + ((_nextChannels$length = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length !== void 0 ? _nextChannels$length : 0);
11017
11040
  newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
11018
11041
  offset: newOffset
11019
11042
  });
11020
11043
 
11021
11044
  _this.state.partialNext({
11022
- channels: [].concat(_toConsumableArray__default['default'](channels || []), _toConsumableArray__default['default'](nextChannels)),
11045
+ channels: uniqBy([].concat(_toConsumableArray__default['default'](channels || []), _toConsumableArray__default['default'](nextChannels)), 'cid'),
11023
11046
  pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
11024
11047
  hasNext: ((_nextChannels$length2 = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length2 !== void 0 ? _nextChannels$length2 : 0) >= limit,
11025
11048
  isLoading: false,
@@ -11028,11 +11051,11 @@ var ChannelManager = function ChannelManager(_ref) {
11028
11051
  })
11029
11052
  });
11030
11053
 
11031
- _context2.next = 20;
11054
+ _context2.next = 21;
11032
11055
  break;
11033
11056
 
11034
- case 15:
11035
- _context2.prev = 15;
11057
+ case 16:
11058
+ _context2.prev = 16;
11036
11059
  _context2.t0 = _context2["catch"](4);
11037
11060
 
11038
11061
  _this.client.logger('error', _context2.t0.message);
@@ -11047,19 +11070,19 @@ var ChannelManager = function ChannelManager(_ref) {
11047
11070
 
11048
11071
  throw _context2.t0;
11049
11072
 
11050
- case 20:
11073
+ case 21:
11051
11074
  case "end":
11052
11075
  return _context2.stop();
11053
11076
  }
11054
11077
  }
11055
- }, _callee2, null, [[4, 15]]);
11078
+ }, _callee2, null, [[4, 16]]);
11056
11079
  })));
11057
11080
 
11058
11081
  _defineProperty__default['default'](this, "notificationAddedToChannelHandler", /*#__PURE__*/function () {
11059
11082
  var _ref6 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(event) {
11060
11083
  var _event$channel, _this$options$allowNo;
11061
11084
 
11062
- var _ref7, id, type, members, channel, _this$state$getLatest4, pagination, channels, _ref9, sort;
11085
+ var _ref7, id, type, members, channel, _this$state$getLatest5, pagination, channels, _ref9, sort;
11063
11086
 
11064
11087
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
11065
11088
  while (1) {
@@ -11095,7 +11118,7 @@ var ChannelManager = function ChannelManager(_ref) {
11095
11118
 
11096
11119
  case 5:
11097
11120
  channel = _context3.sent;
11098
- _this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination, channels = _this$state$getLatest4.channels;
11121
+ _this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination, channels = _this$state$getLatest5.channels;
11099
11122
 
11100
11123
  if (channels) {
11101
11124
  _context3.next = 9;
@@ -11127,8 +11150,8 @@ var ChannelManager = function ChannelManager(_ref) {
11127
11150
  }());
11128
11151
 
11129
11152
  _defineProperty__default['default'](this, "channelDeletedHandler", function (event) {
11130
- var _this$state$getLatest5 = _this.state.getLatestValue(),
11131
- channels = _this$state$getLatest5.channels;
11153
+ var _this$state$getLatest6 = _this.state.getLatestValue(),
11154
+ channels = _this$state$getLatest6.channels;
11132
11155
 
11133
11156
  if (!channels) {
11134
11157
  return;
@@ -11156,9 +11179,9 @@ var ChannelManager = function ChannelManager(_ref) {
11156
11179
  _defineProperty__default['default'](this, "newMessageHandler", function (event) {
11157
11180
  var _this$options$allowNo2;
11158
11181
 
11159
- var _this$state$getLatest6 = _this.state.getLatestValue(),
11160
- pagination = _this$state$getLatest6.pagination,
11161
- channels = _this$state$getLatest6.channels;
11182
+ var _this$state$getLatest7 = _this.state.getLatestValue(),
11183
+ pagination = _this$state$getLatest7.pagination,
11184
+ channels = _this$state$getLatest7.channels;
11162
11185
 
11163
11186
  if (!channels) {
11164
11187
  return;
@@ -11205,37 +11228,37 @@ var ChannelManager = function ChannelManager(_ref) {
11205
11228
  var _ref11 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(event) {
11206
11229
  var _event$channel3, _this$options$allowNo3;
11207
11230
 
11208
- var _ref12, id, type, _this$state$getLatest7, channels, pagination, _ref13, filters, sort, channel, considerArchivedChannels, isTargetChannelArchived;
11231
+ var _ref12, id, type, channel, _this$state$getLatest8, channels, pagination, _ref13, filters, sort, considerArchivedChannels, isTargetChannelArchived;
11209
11232
 
11210
11233
  return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
11211
11234
  while (1) {
11212
11235
  switch (_context4.prev = _context4.next) {
11213
11236
  case 0:
11214
11237
  _ref12 = (_event$channel3 = event === null || event === void 0 ? void 0 : event.channel) !== null && _event$channel3 !== void 0 ? _event$channel3 : {}, id = _ref12.id, type = _ref12.type;
11215
- _this$state$getLatest7 = _this.state.getLatestValue(), channels = _this$state$getLatest7.channels, pagination = _this$state$getLatest7.pagination;
11216
- _ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
11217
11238
 
11218
- if (!(!channels || !id || !type)) {
11219
- _context4.next = 5;
11239
+ if (!(!id || !type)) {
11240
+ _context4.next = 3;
11220
11241
  break;
11221
11242
  }
11222
11243
 
11223
11244
  return _context4.abrupt("return");
11224
11245
 
11225
- case 5:
11226
- _context4.next = 7;
11246
+ case 3:
11247
+ _context4.next = 5;
11227
11248
  return getAndWatchChannel({
11228
11249
  client: _this.client,
11229
11250
  id: id,
11230
11251
  type: type
11231
11252
  });
11232
11253
 
11233
- case 7:
11254
+ case 5:
11234
11255
  channel = _context4.sent;
11256
+ _this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
11257
+ _ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
11235
11258
  considerArchivedChannels = shouldConsiderArchivedChannels(filters);
11236
11259
  isTargetChannelArchived = isChannelArchived(channel);
11237
11260
 
11238
- if (!(considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo3 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo3 !== void 0 && _this$options$allowNo3['notification.message_new']))) {
11261
+ if (!(!channels || considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo3 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo3 !== void 0 && _this$options$allowNo3['notification.message_new']))) {
11239
11262
  _context4.next = 12;
11240
11263
  break;
11241
11264
  }
@@ -11266,37 +11289,37 @@ var ChannelManager = function ChannelManager(_ref) {
11266
11289
  var _ref14 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(event) {
11267
11290
  var _this$options$allowNo4;
11268
11291
 
11269
- var _this$state$getLatest8, channels, pagination, _ref15, sort, filters, channelType, channelId, channel, considerArchivedChannels, isTargetChannelArchived;
11292
+ var channelType, channelId, channel, _this$state$getLatest9, channels, pagination, _ref15, sort, filters, considerArchivedChannels, isTargetChannelArchived;
11270
11293
 
11271
11294
  return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
11272
11295
  while (1) {
11273
11296
  switch (_context5.prev = _context5.next) {
11274
11297
  case 0:
11275
- _this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
11276
- _ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
11277
11298
  channelType = event.channel_type, channelId = event.channel_id;
11278
11299
 
11279
- if (!(!channels || !channelType || !channelId)) {
11280
- _context5.next = 5;
11300
+ if (!(!channelType || !channelId)) {
11301
+ _context5.next = 3;
11281
11302
  break;
11282
11303
  }
11283
11304
 
11284
11305
  return _context5.abrupt("return");
11285
11306
 
11286
- case 5:
11287
- _context5.next = 7;
11307
+ case 3:
11308
+ _context5.next = 5;
11288
11309
  return getAndWatchChannel({
11289
11310
  client: _this.client,
11290
11311
  id: event.channel_id,
11291
11312
  type: event.channel_type
11292
11313
  });
11293
11314
 
11294
- case 7:
11315
+ case 5:
11295
11316
  channel = _context5.sent;
11317
+ _this$state$getLatest9 = _this.state.getLatestValue(), channels = _this$state$getLatest9.channels, pagination = _this$state$getLatest9.pagination;
11318
+ _ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
11296
11319
  considerArchivedChannels = shouldConsiderArchivedChannels(filters);
11297
11320
  isTargetChannelArchived = isChannelArchived(channel);
11298
11321
 
11299
- if (!(considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo4 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo4 !== void 0 && _this$options$allowNo4['channel.visible']))) {
11322
+ if (!(!channels || considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo4 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo4 !== void 0 && _this$options$allowNo4['channel.visible']))) {
11300
11323
  _context5.next = 12;
11301
11324
  break;
11302
11325
  }
@@ -11328,9 +11351,9 @@ var ChannelManager = function ChannelManager(_ref) {
11328
11351
  _defineProperty__default['default'](this, "memberUpdatedHandler", function (event) {
11329
11352
  var _event$member;
11330
11353
 
11331
- var _this$state$getLatest9 = _this.state.getLatestValue(),
11332
- pagination = _this$state$getLatest9.pagination,
11333
- channels = _this$state$getLatest9.channels;
11354
+ var _this$state$getLatest10 = _this.state.getLatestValue(),
11355
+ pagination = _this$state$getLatest10.pagination,
11356
+ channels = _this$state$getLatest10.channels;
11334
11357
 
11335
11358
  var filters = pagination.filters,
11336
11359
  sort = pagination.sort;
@@ -16090,7 +16113,7 @@ var StreamChat = /*#__PURE__*/function () {
16090
16113
  }, {
16091
16114
  key: "getUserAgent",
16092
16115
  value: function getUserAgent() {
16093
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.0");
16116
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.1");
16094
16117
  }
16095
16118
  }, {
16096
16119
  key: "setUserAgent",