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