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/browser.js CHANGED
@@ -423,8 +423,8 @@ function normalizeQuerySort(sort) {
423
423
 
424
424
  try {
425
425
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
426
- var item = _step.value;
427
- var entries = Object.entries(item);
426
+ var _item = _step.value;
427
+ var entries = Object.entries(_item);
428
428
 
429
429
  if (entries.length > 1) {
430
430
  console.warn("client._buildSort() - multiple fields in a single sort object detected. Object's field order is not guaranteed");
@@ -832,6 +832,28 @@ var throttle = function throttle(fn) {
832
832
  runningTimeout = setTimeout(timeoutHandler, timeout);
833
833
  };
834
834
  };
835
+
836
+ var get = function get(obj, path) {
837
+ return path.split('.').reduce(function (acc, key) {
838
+ if (acc && _typeof__default['default'](acc) === 'object' && key in acc) {
839
+ return acc[key];
840
+ }
841
+
842
+ return undefined;
843
+ }, obj);
844
+ }; // works exactly the same as lodash.uniqBy
845
+
846
+
847
+ var uniqBy = function uniqBy(array, iteratee) {
848
+ if (!Array.isArray(array)) return [];
849
+ var seen = new Set();
850
+ return array.filter(function (item) {
851
+ var key = typeof iteratee === 'function' ? iteratee(item) : get(item, iteratee);
852
+ if (seen.has(key)) return false;
853
+ seen.add(key);
854
+ return true;
855
+ });
856
+ };
835
857
  function binarySearchByDateEqualOrNearestGreater(array, targetDate) {
836
858
  var left = 0;
837
859
  var right = array.length - 1;
@@ -10975,13 +10997,13 @@ var ChannelManager = function ChannelManager(_ref) {
10975
10997
  }());
10976
10998
 
10977
10999
  _defineProperty__default['default'](this, "loadNext", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
10978
- var _this$state$getLatest3, pagination, channels, initialized, filters, sort, options, isLoadingNext, hasNext, _nextChannels$length, _nextChannels$length2, _DEFAULT_CHANNEL_MANA2, offset, limit, nextChannels, newOffset, newOptions;
11000
+ 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;
10979
11001
 
10980
11002
  return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
10981
11003
  while (1) {
10982
11004
  switch (_context2.prev = _context2.next) {
10983
11005
  case 0:
10984
- _this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, channels = _this$state$getLatest3.channels, initialized = _this$state$getLatest3.initialized;
11006
+ _this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, initialized = _this$state$getLatest3.initialized;
10985
11007
  filters = pagination.filters, sort = pagination.sort, options = pagination.options, isLoadingNext = pagination.isLoadingNext, hasNext = pagination.hasNext;
10986
11008
 
10987
11009
  if (!(!initialized || isLoadingNext || !hasNext)) {
@@ -11007,13 +11029,14 @@ var ChannelManager = function ChannelManager(_ref) {
11007
11029
 
11008
11030
  case 9:
11009
11031
  nextChannels = _context2.sent;
11032
+ _this$state$getLatest4 = _this.state.getLatestValue(), channels = _this$state$getLatest4.channels;
11010
11033
  newOffset = offset + ((_nextChannels$length = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length !== void 0 ? _nextChannels$length : 0);
11011
11034
  newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
11012
11035
  offset: newOffset
11013
11036
  });
11014
11037
 
11015
11038
  _this.state.partialNext({
11016
- channels: [].concat(_toConsumableArray__default['default'](channels || []), _toConsumableArray__default['default'](nextChannels)),
11039
+ channels: uniqBy([].concat(_toConsumableArray__default['default'](channels || []), _toConsumableArray__default['default'](nextChannels)), 'cid'),
11017
11040
  pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
11018
11041
  hasNext: ((_nextChannels$length2 = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length2 !== void 0 ? _nextChannels$length2 : 0) >= limit,
11019
11042
  isLoading: false,
@@ -11022,11 +11045,11 @@ var ChannelManager = function ChannelManager(_ref) {
11022
11045
  })
11023
11046
  });
11024
11047
 
11025
- _context2.next = 20;
11048
+ _context2.next = 21;
11026
11049
  break;
11027
11050
 
11028
- case 15:
11029
- _context2.prev = 15;
11051
+ case 16:
11052
+ _context2.prev = 16;
11030
11053
  _context2.t0 = _context2["catch"](4);
11031
11054
 
11032
11055
  _this.client.logger('error', _context2.t0.message);
@@ -11041,19 +11064,19 @@ var ChannelManager = function ChannelManager(_ref) {
11041
11064
 
11042
11065
  throw _context2.t0;
11043
11066
 
11044
- case 20:
11067
+ case 21:
11045
11068
  case "end":
11046
11069
  return _context2.stop();
11047
11070
  }
11048
11071
  }
11049
- }, _callee2, null, [[4, 15]]);
11072
+ }, _callee2, null, [[4, 16]]);
11050
11073
  })));
11051
11074
 
11052
11075
  _defineProperty__default['default'](this, "notificationAddedToChannelHandler", /*#__PURE__*/function () {
11053
11076
  var _ref6 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(event) {
11054
11077
  var _event$channel, _this$options$allowNo;
11055
11078
 
11056
- var _ref7, id, type, members, channel, _this$state$getLatest4, pagination, channels, _ref9, sort;
11079
+ var _ref7, id, type, members, channel, _this$state$getLatest5, pagination, channels, _ref9, sort;
11057
11080
 
11058
11081
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
11059
11082
  while (1) {
@@ -11089,7 +11112,7 @@ var ChannelManager = function ChannelManager(_ref) {
11089
11112
 
11090
11113
  case 5:
11091
11114
  channel = _context3.sent;
11092
- _this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination, channels = _this$state$getLatest4.channels;
11115
+ _this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination, channels = _this$state$getLatest5.channels;
11093
11116
 
11094
11117
  if (channels) {
11095
11118
  _context3.next = 9;
@@ -11121,8 +11144,8 @@ var ChannelManager = function ChannelManager(_ref) {
11121
11144
  }());
11122
11145
 
11123
11146
  _defineProperty__default['default'](this, "channelDeletedHandler", function (event) {
11124
- var _this$state$getLatest5 = _this.state.getLatestValue(),
11125
- channels = _this$state$getLatest5.channels;
11147
+ var _this$state$getLatest6 = _this.state.getLatestValue(),
11148
+ channels = _this$state$getLatest6.channels;
11126
11149
 
11127
11150
  if (!channels) {
11128
11151
  return;
@@ -11150,9 +11173,9 @@ var ChannelManager = function ChannelManager(_ref) {
11150
11173
  _defineProperty__default['default'](this, "newMessageHandler", function (event) {
11151
11174
  var _this$options$allowNo2;
11152
11175
 
11153
- var _this$state$getLatest6 = _this.state.getLatestValue(),
11154
- pagination = _this$state$getLatest6.pagination,
11155
- channels = _this$state$getLatest6.channels;
11176
+ var _this$state$getLatest7 = _this.state.getLatestValue(),
11177
+ pagination = _this$state$getLatest7.pagination,
11178
+ channels = _this$state$getLatest7.channels;
11156
11179
 
11157
11180
  if (!channels) {
11158
11181
  return;
@@ -11199,37 +11222,37 @@ var ChannelManager = function ChannelManager(_ref) {
11199
11222
  var _ref11 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(event) {
11200
11223
  var _event$channel3, _this$options$allowNo3;
11201
11224
 
11202
- var _ref12, id, type, _this$state$getLatest7, channels, pagination, _ref13, filters, sort, channel, considerArchivedChannels, isTargetChannelArchived;
11225
+ var _ref12, id, type, channel, _this$state$getLatest8, channels, pagination, _ref13, filters, sort, considerArchivedChannels, isTargetChannelArchived;
11203
11226
 
11204
11227
  return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
11205
11228
  while (1) {
11206
11229
  switch (_context4.prev = _context4.next) {
11207
11230
  case 0:
11208
11231
  _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;
11209
- _this$state$getLatest7 = _this.state.getLatestValue(), channels = _this$state$getLatest7.channels, pagination = _this$state$getLatest7.pagination;
11210
- _ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
11211
11232
 
11212
- if (!(!channels || !id || !type)) {
11213
- _context4.next = 5;
11233
+ if (!(!id || !type)) {
11234
+ _context4.next = 3;
11214
11235
  break;
11215
11236
  }
11216
11237
 
11217
11238
  return _context4.abrupt("return");
11218
11239
 
11219
- case 5:
11220
- _context4.next = 7;
11240
+ case 3:
11241
+ _context4.next = 5;
11221
11242
  return getAndWatchChannel({
11222
11243
  client: _this.client,
11223
11244
  id: id,
11224
11245
  type: type
11225
11246
  });
11226
11247
 
11227
- case 7:
11248
+ case 5:
11228
11249
  channel = _context4.sent;
11250
+ _this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
11251
+ _ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
11229
11252
  considerArchivedChannels = shouldConsiderArchivedChannels(filters);
11230
11253
  isTargetChannelArchived = isChannelArchived(channel);
11231
11254
 
11232
- 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']))) {
11255
+ 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']))) {
11233
11256
  _context4.next = 12;
11234
11257
  break;
11235
11258
  }
@@ -11260,37 +11283,37 @@ var ChannelManager = function ChannelManager(_ref) {
11260
11283
  var _ref14 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(event) {
11261
11284
  var _this$options$allowNo4;
11262
11285
 
11263
- var _this$state$getLatest8, channels, pagination, _ref15, sort, filters, channelType, channelId, channel, considerArchivedChannels, isTargetChannelArchived;
11286
+ var channelType, channelId, channel, _this$state$getLatest9, channels, pagination, _ref15, sort, filters, considerArchivedChannels, isTargetChannelArchived;
11264
11287
 
11265
11288
  return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
11266
11289
  while (1) {
11267
11290
  switch (_context5.prev = _context5.next) {
11268
11291
  case 0:
11269
- _this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
11270
- _ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
11271
11292
  channelType = event.channel_type, channelId = event.channel_id;
11272
11293
 
11273
- if (!(!channels || !channelType || !channelId)) {
11274
- _context5.next = 5;
11294
+ if (!(!channelType || !channelId)) {
11295
+ _context5.next = 3;
11275
11296
  break;
11276
11297
  }
11277
11298
 
11278
11299
  return _context5.abrupt("return");
11279
11300
 
11280
- case 5:
11281
- _context5.next = 7;
11301
+ case 3:
11302
+ _context5.next = 5;
11282
11303
  return getAndWatchChannel({
11283
11304
  client: _this.client,
11284
11305
  id: event.channel_id,
11285
11306
  type: event.channel_type
11286
11307
  });
11287
11308
 
11288
- case 7:
11309
+ case 5:
11289
11310
  channel = _context5.sent;
11311
+ _this$state$getLatest9 = _this.state.getLatestValue(), channels = _this$state$getLatest9.channels, pagination = _this$state$getLatest9.pagination;
11312
+ _ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
11290
11313
  considerArchivedChannels = shouldConsiderArchivedChannels(filters);
11291
11314
  isTargetChannelArchived = isChannelArchived(channel);
11292
11315
 
11293
- 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']))) {
11316
+ 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']))) {
11294
11317
  _context5.next = 12;
11295
11318
  break;
11296
11319
  }
@@ -11322,9 +11345,9 @@ var ChannelManager = function ChannelManager(_ref) {
11322
11345
  _defineProperty__default['default'](this, "memberUpdatedHandler", function (event) {
11323
11346
  var _event$member;
11324
11347
 
11325
- var _this$state$getLatest9 = _this.state.getLatestValue(),
11326
- pagination = _this$state$getLatest9.pagination,
11327
- channels = _this$state$getLatest9.channels;
11348
+ var _this$state$getLatest10 = _this.state.getLatestValue(),
11349
+ pagination = _this$state$getLatest10.pagination,
11350
+ channels = _this$state$getLatest10.channels;
11328
11351
 
11329
11352
  var filters = pagination.filters,
11330
11353
  sort = pagination.sort;
@@ -16084,7 +16107,7 @@ var StreamChat = /*#__PURE__*/function () {
16084
16107
  }, {
16085
16108
  key: "getUserAgent",
16086
16109
  value: function getUserAgent() {
16087
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.0");
16110
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.1");
16088
16111
  }
16089
16112
  }, {
16090
16113
  key: "setUserAgent",