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