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.js CHANGED
@@ -1514,7 +1514,7 @@ var Channel = /*#__PURE__*/function () {
1514
1514
  return this._client;
1515
1515
  }
1516
1516
  /**
1517
- * getConfig - Get the configs for this channel type
1517
+ * getConfig - Get the config for this channel id (cid)
1518
1518
  *
1519
1519
  * @return {Record<string, unknown>}
1520
1520
  */
@@ -1523,7 +1523,7 @@ var Channel = /*#__PURE__*/function () {
1523
1523
  key: "getConfig",
1524
1524
  value: function getConfig() {
1525
1525
  var client = this.getClient();
1526
- return client.configs[this.type];
1526
+ return client.configs[this.cid];
1527
1527
  }
1528
1528
  /**
1529
1529
  * sendMessage - Send a message to this channel
@@ -3192,7 +3192,7 @@ var Channel = /*#__PURE__*/function () {
3192
3192
  }
3193
3193
  }
3194
3194
 
3195
- this.getClient()._addChannelConfig(state); // add any messages to our channel state
3195
+ this.getClient()._addChannelConfig(state.channel); // add any messages to our channel state
3196
3196
 
3197
3197
 
3198
3198
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
@@ -3917,22 +3917,13 @@ var Channel = /*#__PURE__*/function () {
3917
3917
  }
3918
3918
 
3919
3919
  if (state.members) {
3920
- var _iterator4 = _createForOfIteratorHelper$2(state.members),
3921
- _step4;
3922
-
3923
- try {
3924
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3925
- var _member = _step4.value;
3926
-
3927
- if (_member.user) {
3928
- this.state.members[_member.user.id] = _member;
3929
- }
3920
+ this.state.members = state.members.reduce(function (acc, member) {
3921
+ if (member.user) {
3922
+ acc[member.user.id] = member;
3930
3923
  }
3931
- } catch (err) {
3932
- _iterator4.e(err);
3933
- } finally {
3934
- _iterator4.f();
3935
- }
3924
+
3925
+ return acc;
3926
+ }, {});
3936
3927
  }
3937
3928
 
3938
3929
  return {
@@ -6085,6 +6076,8 @@ var StreamChat = /*#__PURE__*/function () {
6085
6076
 
6086
6077
  _defineProperty__default['default'](this, "defaultWSTimeout", void 0);
6087
6078
 
6079
+ _defineProperty__default['default'](this, "nextRequestAbortController", null);
6080
+
6088
6081
  _defineProperty__default['default'](this, "_getConnectionID", function () {
6089
6082
  var _this$wsConnection, _this$wsFallback;
6090
6083
 
@@ -7576,7 +7569,7 @@ var StreamChat = /*#__PURE__*/function () {
7576
7569
  }
7577
7570
 
7578
7571
  if (event.channel && event.type === 'notification.message_new') {
7579
- this.configs[event.channel.type] = event.channel.config;
7572
+ this._addChannelConfig(event.channel);
7580
7573
  }
7581
7574
 
7582
7575
  if (event.type === 'notification.channel_mutes_updated' && (_event$me = event.me) !== null && _event$me !== void 0 && _event$me.channel_mutes) {
@@ -8053,7 +8046,7 @@ var StreamChat = /*#__PURE__*/function () {
8053
8046
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
8054
8047
  var channelState = _step2.value;
8055
8048
 
8056
- this._addChannelConfig(channelState);
8049
+ this._addChannelConfig(channelState.channel);
8057
8050
  }
8058
8051
  } catch (err) {
8059
8052
  _iterator2.e(err);
@@ -8374,8 +8367,10 @@ var StreamChat = /*#__PURE__*/function () {
8374
8367
  }()
8375
8368
  }, {
8376
8369
  key: "_addChannelConfig",
8377
- value: function _addChannelConfig(channelState) {
8378
- this.configs[channelState.channel.type] = channelState.channel.config;
8370
+ value: function _addChannelConfig(_ref8) {
8371
+ var cid = _ref8.cid,
8372
+ config = _ref8.config;
8373
+ this.configs[cid] = config;
8379
8374
  }
8380
8375
  /**
8381
8376
  * channel - Returns a new channel with the given type, id and custom data
@@ -9854,7 +9849,7 @@ var StreamChat = /*#__PURE__*/function () {
9854
9849
  }, {
9855
9850
  key: "getUserAgent",
9856
9851
  value: function getUserAgent() {
9857
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.1.0");
9852
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.2.0");
9858
9853
  }
9859
9854
  }, {
9860
9855
  key: "setUserAgent",
@@ -9881,6 +9876,12 @@ var StreamChat = /*#__PURE__*/function () {
9881
9876
  var authorization = token ? {
9882
9877
  Authorization: token
9883
9878
  } : undefined;
9879
+ var signal = null;
9880
+
9881
+ if (this.nextRequestAbortController !== null) {
9882
+ signal = this.nextRequestAbortController.signal;
9883
+ this.nextRequestAbortController = null;
9884
+ }
9884
9885
 
9885
9886
  if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
9886
9887
  options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
@@ -9888,7 +9889,7 @@ var StreamChat = /*#__PURE__*/function () {
9888
9889
  });
9889
9890
  }
9890
9891
 
9891
- return _objectSpread({
9892
+ return _objectSpread(_objectSpread({
9892
9893
  params: _objectSpread({
9893
9894
  user_id: this.userID,
9894
9895
  connection_id: this._getConnectionID(),
@@ -9898,7 +9899,9 @@ var StreamChat = /*#__PURE__*/function () {
9898
9899
  'stream-auth-type': this.getAuthType(),
9899
9900
  'X-Stream-Client': this.getUserAgent()
9900
9901
  }, options.headers)
9901
- }, options.config);
9902
+ }, signal ? {
9903
+ signal: signal
9904
+ } : {}), options.config);
9902
9905
  }
9903
9906
  }, {
9904
9907
  key: "_getToken",
@@ -11054,13 +11057,13 @@ var StreamChat = /*#__PURE__*/function () {
11054
11057
  }, {
11055
11058
  key: "deletePushProvider",
11056
11059
  value: function () {
11057
- var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref8) {
11060
+ var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref9) {
11058
11061
  var type, name;
11059
11062
  return _regeneratorRuntime__default['default'].wrap(function _callee76$(_context76) {
11060
11063
  while (1) {
11061
11064
  switch (_context76.prev = _context76.next) {
11062
11065
  case 0:
11063
- type = _ref8.type, name = _ref8.name;
11066
+ type = _ref9.type, name = _ref9.name;
11064
11067
  _context76.next = 3;
11065
11068
  return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
11066
11069
 
@@ -11117,6 +11120,15 @@ var StreamChat = /*#__PURE__*/function () {
11117
11120
 
11118
11121
  return listPushProviders;
11119
11122
  }()
11123
+ /**
11124
+ * creates an abort controller that will be used by the next HTTP Request.
11125
+ */
11126
+
11127
+ }, {
11128
+ key: "createAbortControllerForNextRequest",
11129
+ value: function createAbortControllerForNextRequest() {
11130
+ return this.nextRequestAbortController = new AbortController();
11131
+ }
11120
11132
  }], [{
11121
11133
  key: "getInstance",
11122
11134
  value: function getInstance(key, secretOrOptions, options) {