stream-chat 7.1.0 → 8.0.0-dev.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/browser.js CHANGED
@@ -1267,7 +1267,9 @@ function getRandomValuesWithMathRandom(bytes) {
1267
1267
  }
1268
1268
 
1269
1269
  var getRandomValues = function () {
1270
- if (typeof crypto !== 'undefined') {
1270
+ var _crypto;
1271
+
1272
+ if (typeof crypto !== 'undefined' && typeof ((_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.getRandomValues) !== 'undefined') {
1271
1273
  return crypto.getRandomValues.bind(crypto);
1272
1274
  } else if (typeof msCrypto !== 'undefined') {
1273
1275
  return msCrypto.getRandomValues.bind(msCrypto);
@@ -1510,7 +1512,7 @@ var Channel = /*#__PURE__*/function () {
1510
1512
  return this._client;
1511
1513
  }
1512
1514
  /**
1513
- * getConfig - Get the configs for this channel type
1515
+ * getConfig - Get the config for this channel id (cid)
1514
1516
  *
1515
1517
  * @return {Record<string, unknown>}
1516
1518
  */
@@ -1519,7 +1521,7 @@ var Channel = /*#__PURE__*/function () {
1519
1521
  key: "getConfig",
1520
1522
  value: function getConfig() {
1521
1523
  var client = this.getClient();
1522
- return client.configs[this.type];
1524
+ return client.configs[this.cid];
1523
1525
  }
1524
1526
  /**
1525
1527
  * sendMessage - Send a message to this channel
@@ -3188,7 +3190,7 @@ var Channel = /*#__PURE__*/function () {
3188
3190
  }
3189
3191
  }
3190
3192
 
3191
- this.getClient()._addChannelConfig(state); // add any messages to our channel state
3193
+ this.getClient()._addChannelConfig(state.channel); // add any messages to our channel state
3192
3194
 
3193
3195
 
3194
3196
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
@@ -3913,22 +3915,13 @@ var Channel = /*#__PURE__*/function () {
3913
3915
  }
3914
3916
 
3915
3917
  if (state.members) {
3916
- var _iterator4 = _createForOfIteratorHelper$2(state.members),
3917
- _step4;
3918
-
3919
- try {
3920
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3921
- var _member = _step4.value;
3922
-
3923
- if (_member.user) {
3924
- this.state.members[_member.user.id] = _member;
3925
- }
3918
+ this.state.members = state.members.reduce(function (acc, member) {
3919
+ if (member.user) {
3920
+ acc[member.user.id] = member;
3926
3921
  }
3927
- } catch (err) {
3928
- _iterator4.e(err);
3929
- } finally {
3930
- _iterator4.f();
3931
- }
3922
+
3923
+ return acc;
3924
+ }, {});
3932
3925
  }
3933
3926
 
3934
3927
  return {
@@ -6079,6 +6072,8 @@ var StreamChat = /*#__PURE__*/function () {
6079
6072
 
6080
6073
  _defineProperty__default['default'](this, "defaultWSTimeout", void 0);
6081
6074
 
6075
+ _defineProperty__default['default'](this, "nextRequestAbortController", null);
6076
+
6082
6077
  _defineProperty__default['default'](this, "_getConnectionID", function () {
6083
6078
  var _this$wsConnection, _this$wsFallback;
6084
6079
 
@@ -7570,7 +7565,7 @@ var StreamChat = /*#__PURE__*/function () {
7570
7565
  }
7571
7566
 
7572
7567
  if (event.channel && event.type === 'notification.message_new') {
7573
- this.configs[event.channel.type] = event.channel.config;
7568
+ this._addChannelConfig(event.channel);
7574
7569
  }
7575
7570
 
7576
7571
  if (event.type === 'notification.channel_mutes_updated' && (_event$me = event.me) !== null && _event$me !== void 0 && _event$me.channel_mutes) {
@@ -8047,7 +8042,7 @@ var StreamChat = /*#__PURE__*/function () {
8047
8042
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
8048
8043
  var channelState = _step2.value;
8049
8044
 
8050
- this._addChannelConfig(channelState);
8045
+ this._addChannelConfig(channelState.channel);
8051
8046
  }
8052
8047
  } catch (err) {
8053
8048
  _iterator2.e(err);
@@ -8368,8 +8363,10 @@ var StreamChat = /*#__PURE__*/function () {
8368
8363
  }()
8369
8364
  }, {
8370
8365
  key: "_addChannelConfig",
8371
- value: function _addChannelConfig(channelState) {
8372
- this.configs[channelState.channel.type] = channelState.channel.config;
8366
+ value: function _addChannelConfig(_ref8) {
8367
+ var cid = _ref8.cid,
8368
+ config = _ref8.config;
8369
+ this.configs[cid] = config;
8373
8370
  }
8374
8371
  /**
8375
8372
  * channel - Returns a new channel with the given type, id and custom data
@@ -9848,7 +9845,7 @@ var StreamChat = /*#__PURE__*/function () {
9848
9845
  }, {
9849
9846
  key: "getUserAgent",
9850
9847
  value: function getUserAgent() {
9851
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.1.0");
9848
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.0.0-dev.0");
9852
9849
  }
9853
9850
  }, {
9854
9851
  key: "setUserAgent",
@@ -9875,6 +9872,12 @@ var StreamChat = /*#__PURE__*/function () {
9875
9872
  var authorization = token ? {
9876
9873
  Authorization: token
9877
9874
  } : undefined;
9875
+ var signal = null;
9876
+
9877
+ if (this.nextRequestAbortController !== null) {
9878
+ signal = this.nextRequestAbortController.signal;
9879
+ this.nextRequestAbortController = null;
9880
+ }
9878
9881
 
9879
9882
  if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
9880
9883
  options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
@@ -9882,7 +9885,7 @@ var StreamChat = /*#__PURE__*/function () {
9882
9885
  });
9883
9886
  }
9884
9887
 
9885
- return _objectSpread({
9888
+ return _objectSpread(_objectSpread({
9886
9889
  params: _objectSpread({
9887
9890
  user_id: this.userID,
9888
9891
  connection_id: this._getConnectionID(),
@@ -9892,7 +9895,9 @@ var StreamChat = /*#__PURE__*/function () {
9892
9895
  'stream-auth-type': this.getAuthType(),
9893
9896
  'X-Stream-Client': this.getUserAgent()
9894
9897
  }, options.headers)
9895
- }, options.config);
9898
+ }, signal ? {
9899
+ signal: signal
9900
+ } : {}), options.config);
9896
9901
  }
9897
9902
  }, {
9898
9903
  key: "_getToken",
@@ -11048,13 +11053,13 @@ var StreamChat = /*#__PURE__*/function () {
11048
11053
  }, {
11049
11054
  key: "deletePushProvider",
11050
11055
  value: function () {
11051
- var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref8) {
11056
+ var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref9) {
11052
11057
  var type, name;
11053
11058
  return _regeneratorRuntime__default['default'].wrap(function _callee76$(_context76) {
11054
11059
  while (1) {
11055
11060
  switch (_context76.prev = _context76.next) {
11056
11061
  case 0:
11057
- type = _ref8.type, name = _ref8.name;
11062
+ type = _ref9.type, name = _ref9.name;
11058
11063
  _context76.next = 3;
11059
11064
  return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
11060
11065
 
@@ -11111,6 +11116,15 @@ var StreamChat = /*#__PURE__*/function () {
11111
11116
 
11112
11117
  return listPushProviders;
11113
11118
  }()
11119
+ /**
11120
+ * creates an abort controller that will be used by the next HTTP Request.
11121
+ */
11122
+
11123
+ }, {
11124
+ key: "createAbortControllerForNextRequest",
11125
+ value: function createAbortControllerForNextRequest() {
11126
+ return this.nextRequestAbortController = new AbortController();
11127
+ }
11114
11128
  }], [{
11115
11129
  key: "getInstance",
11116
11130
  value: function getInstance(key, secretOrOptions, options) {