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