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/index.es.js CHANGED
@@ -1243,7 +1243,9 @@ function getRandomValuesWithMathRandom(bytes) {
1243
1243
  }
1244
1244
 
1245
1245
  var getRandomValues = function () {
1246
- if (typeof crypto !== 'undefined') {
1246
+ var _crypto;
1247
+
1248
+ if (typeof crypto !== 'undefined' && typeof ((_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.getRandomValues) !== 'undefined') {
1247
1249
  return crypto.getRandomValues.bind(crypto);
1248
1250
  } else if (typeof msCrypto !== 'undefined') {
1249
1251
  return msCrypto.getRandomValues.bind(msCrypto);
@@ -1486,7 +1488,7 @@ var Channel = /*#__PURE__*/function () {
1486
1488
  return this._client;
1487
1489
  }
1488
1490
  /**
1489
- * getConfig - Get the configs for this channel type
1491
+ * getConfig - Get the config for this channel id (cid)
1490
1492
  *
1491
1493
  * @return {Record<string, unknown>}
1492
1494
  */
@@ -1495,7 +1497,7 @@ var Channel = /*#__PURE__*/function () {
1495
1497
  key: "getConfig",
1496
1498
  value: function getConfig() {
1497
1499
  var client = this.getClient();
1498
- return client.configs[this.type];
1500
+ return client.configs[this.cid];
1499
1501
  }
1500
1502
  /**
1501
1503
  * sendMessage - Send a message to this channel
@@ -3164,7 +3166,7 @@ var Channel = /*#__PURE__*/function () {
3164
3166
  }
3165
3167
  }
3166
3168
 
3167
- this.getClient()._addChannelConfig(state); // add any messages to our channel state
3169
+ this.getClient()._addChannelConfig(state.channel); // add any messages to our channel state
3168
3170
 
3169
3171
 
3170
3172
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
@@ -3889,22 +3891,13 @@ var Channel = /*#__PURE__*/function () {
3889
3891
  }
3890
3892
 
3891
3893
  if (state.members) {
3892
- var _iterator4 = _createForOfIteratorHelper$2(state.members),
3893
- _step4;
3894
-
3895
- try {
3896
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3897
- var _member = _step4.value;
3898
-
3899
- if (_member.user) {
3900
- this.state.members[_member.user.id] = _member;
3901
- }
3894
+ this.state.members = state.members.reduce(function (acc, member) {
3895
+ if (member.user) {
3896
+ acc[member.user.id] = member;
3902
3897
  }
3903
- } catch (err) {
3904
- _iterator4.e(err);
3905
- } finally {
3906
- _iterator4.f();
3907
- }
3898
+
3899
+ return acc;
3900
+ }, {});
3908
3901
  }
3909
3902
 
3910
3903
  return {
@@ -6057,6 +6050,8 @@ var StreamChat = /*#__PURE__*/function () {
6057
6050
 
6058
6051
  _defineProperty(this, "defaultWSTimeout", void 0);
6059
6052
 
6053
+ _defineProperty(this, "nextRequestAbortController", null);
6054
+
6060
6055
  _defineProperty(this, "_getConnectionID", function () {
6061
6056
  var _this$wsConnection, _this$wsFallback;
6062
6057
 
@@ -7548,7 +7543,7 @@ var StreamChat = /*#__PURE__*/function () {
7548
7543
  }
7549
7544
 
7550
7545
  if (event.channel && event.type === 'notification.message_new') {
7551
- this.configs[event.channel.type] = event.channel.config;
7546
+ this._addChannelConfig(event.channel);
7552
7547
  }
7553
7548
 
7554
7549
  if (event.type === 'notification.channel_mutes_updated' && (_event$me = event.me) !== null && _event$me !== void 0 && _event$me.channel_mutes) {
@@ -8025,7 +8020,7 @@ var StreamChat = /*#__PURE__*/function () {
8025
8020
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
8026
8021
  var channelState = _step2.value;
8027
8022
 
8028
- this._addChannelConfig(channelState);
8023
+ this._addChannelConfig(channelState.channel);
8029
8024
  }
8030
8025
  } catch (err) {
8031
8026
  _iterator2.e(err);
@@ -8346,8 +8341,10 @@ var StreamChat = /*#__PURE__*/function () {
8346
8341
  }()
8347
8342
  }, {
8348
8343
  key: "_addChannelConfig",
8349
- value: function _addChannelConfig(channelState) {
8350
- this.configs[channelState.channel.type] = channelState.channel.config;
8344
+ value: function _addChannelConfig(_ref8) {
8345
+ var cid = _ref8.cid,
8346
+ config = _ref8.config;
8347
+ this.configs[cid] = config;
8351
8348
  }
8352
8349
  /**
8353
8350
  * channel - Returns a new channel with the given type, id and custom data
@@ -9826,7 +9823,7 @@ var StreamChat = /*#__PURE__*/function () {
9826
9823
  }, {
9827
9824
  key: "getUserAgent",
9828
9825
  value: function getUserAgent() {
9829
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.1.0");
9826
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.0.0-dev.0");
9830
9827
  }
9831
9828
  }, {
9832
9829
  key: "setUserAgent",
@@ -9853,6 +9850,12 @@ var StreamChat = /*#__PURE__*/function () {
9853
9850
  var authorization = token ? {
9854
9851
  Authorization: token
9855
9852
  } : undefined;
9853
+ var signal = null;
9854
+
9855
+ if (this.nextRequestAbortController !== null) {
9856
+ signal = this.nextRequestAbortController.signal;
9857
+ this.nextRequestAbortController = null;
9858
+ }
9856
9859
 
9857
9860
  if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
9858
9861
  options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
@@ -9860,7 +9863,7 @@ var StreamChat = /*#__PURE__*/function () {
9860
9863
  });
9861
9864
  }
9862
9865
 
9863
- return _objectSpread({
9866
+ return _objectSpread(_objectSpread({
9864
9867
  params: _objectSpread({
9865
9868
  user_id: this.userID,
9866
9869
  connection_id: this._getConnectionID(),
@@ -9870,7 +9873,9 @@ var StreamChat = /*#__PURE__*/function () {
9870
9873
  'stream-auth-type': this.getAuthType(),
9871
9874
  'X-Stream-Client': this.getUserAgent()
9872
9875
  }, options.headers)
9873
- }, options.config);
9876
+ }, signal ? {
9877
+ signal: signal
9878
+ } : {}), options.config);
9874
9879
  }
9875
9880
  }, {
9876
9881
  key: "_getToken",
@@ -11026,13 +11031,13 @@ var StreamChat = /*#__PURE__*/function () {
11026
11031
  }, {
11027
11032
  key: "deletePushProvider",
11028
11033
  value: function () {
11029
- var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee76(_ref8) {
11034
+ var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee76(_ref9) {
11030
11035
  var type, name;
11031
11036
  return _regeneratorRuntime.wrap(function _callee76$(_context76) {
11032
11037
  while (1) {
11033
11038
  switch (_context76.prev = _context76.next) {
11034
11039
  case 0:
11035
- type = _ref8.type, name = _ref8.name;
11040
+ type = _ref9.type, name = _ref9.name;
11036
11041
  _context76.next = 3;
11037
11042
  return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
11038
11043
 
@@ -11089,6 +11094,15 @@ var StreamChat = /*#__PURE__*/function () {
11089
11094
 
11090
11095
  return listPushProviders;
11091
11096
  }()
11097
+ /**
11098
+ * creates an abort controller that will be used by the next HTTP Request.
11099
+ */
11100
+
11101
+ }, {
11102
+ key: "createAbortControllerForNextRequest",
11103
+ value: function createAbortControllerForNextRequest() {
11104
+ return this.nextRequestAbortController = new AbortController();
11105
+ }
11092
11106
  }], [{
11093
11107
  key: "getInstance",
11094
11108
  value: function getInstance(key, secretOrOptions, options) {