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/browser.js CHANGED
@@ -1510,7 +1510,7 @@ var Channel = /*#__PURE__*/function () {
1510
1510
  return this._client;
1511
1511
  }
1512
1512
  /**
1513
- * getConfig - Get the configs for this channel type
1513
+ * getConfig - Get the config for this channel id (cid)
1514
1514
  *
1515
1515
  * @return {Record<string, unknown>}
1516
1516
  */
@@ -1519,7 +1519,7 @@ var Channel = /*#__PURE__*/function () {
1519
1519
  key: "getConfig",
1520
1520
  value: function getConfig() {
1521
1521
  var client = this.getClient();
1522
- return client.configs[this.type];
1522
+ return client.configs[this.cid];
1523
1523
  }
1524
1524
  /**
1525
1525
  * sendMessage - Send a message to this channel
@@ -3188,7 +3188,7 @@ var Channel = /*#__PURE__*/function () {
3188
3188
  }
3189
3189
  }
3190
3190
 
3191
- this.getClient()._addChannelConfig(state); // add any messages to our channel state
3191
+ this.getClient()._addChannelConfig(state.channel); // add any messages to our channel state
3192
3192
 
3193
3193
 
3194
3194
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
@@ -3913,22 +3913,13 @@ var Channel = /*#__PURE__*/function () {
3913
3913
  }
3914
3914
 
3915
3915
  if (state.members) {
3916
- var _iterator4 = _createForOfIteratorHelper$2(state.members),
3917
- _step4;
3918
-
3919
- try {
3920
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3921
- var _member = _step4.value;
3922
-
3923
- if (_member.user) {
3924
- this.state.members[_member.user.id] = _member;
3925
- }
3916
+ this.state.members = state.members.reduce(function (acc, member) {
3917
+ if (member.user) {
3918
+ acc[member.user.id] = member;
3926
3919
  }
3927
- } catch (err) {
3928
- _iterator4.e(err);
3929
- } finally {
3930
- _iterator4.f();
3931
- }
3920
+
3921
+ return acc;
3922
+ }, {});
3932
3923
  }
3933
3924
 
3934
3925
  return {
@@ -6079,6 +6070,8 @@ var StreamChat = /*#__PURE__*/function () {
6079
6070
 
6080
6071
  _defineProperty__default['default'](this, "defaultWSTimeout", void 0);
6081
6072
 
6073
+ _defineProperty__default['default'](this, "nextRequestAbortController", null);
6074
+
6082
6075
  _defineProperty__default['default'](this, "_getConnectionID", function () {
6083
6076
  var _this$wsConnection, _this$wsFallback;
6084
6077
 
@@ -7570,7 +7563,7 @@ var StreamChat = /*#__PURE__*/function () {
7570
7563
  }
7571
7564
 
7572
7565
  if (event.channel && event.type === 'notification.message_new') {
7573
- this.configs[event.channel.type] = event.channel.config;
7566
+ this._addChannelConfig(event.channel);
7574
7567
  }
7575
7568
 
7576
7569
  if (event.type === 'notification.channel_mutes_updated' && (_event$me = event.me) !== null && _event$me !== void 0 && _event$me.channel_mutes) {
@@ -8047,7 +8040,7 @@ var StreamChat = /*#__PURE__*/function () {
8047
8040
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
8048
8041
  var channelState = _step2.value;
8049
8042
 
8050
- this._addChannelConfig(channelState);
8043
+ this._addChannelConfig(channelState.channel);
8051
8044
  }
8052
8045
  } catch (err) {
8053
8046
  _iterator2.e(err);
@@ -8368,8 +8361,10 @@ var StreamChat = /*#__PURE__*/function () {
8368
8361
  }()
8369
8362
  }, {
8370
8363
  key: "_addChannelConfig",
8371
- value: function _addChannelConfig(channelState) {
8372
- this.configs[channelState.channel.type] = channelState.channel.config;
8364
+ value: function _addChannelConfig(_ref8) {
8365
+ var cid = _ref8.cid,
8366
+ config = _ref8.config;
8367
+ this.configs[cid] = config;
8373
8368
  }
8374
8369
  /**
8375
8370
  * channel - Returns a new channel with the given type, id and custom data
@@ -9848,7 +9843,7 @@ var StreamChat = /*#__PURE__*/function () {
9848
9843
  }, {
9849
9844
  key: "getUserAgent",
9850
9845
  value: function getUserAgent() {
9851
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.1.0");
9846
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.2.0");
9852
9847
  }
9853
9848
  }, {
9854
9849
  key: "setUserAgent",
@@ -9875,6 +9870,12 @@ var StreamChat = /*#__PURE__*/function () {
9875
9870
  var authorization = token ? {
9876
9871
  Authorization: token
9877
9872
  } : undefined;
9873
+ var signal = null;
9874
+
9875
+ if (this.nextRequestAbortController !== null) {
9876
+ signal = this.nextRequestAbortController.signal;
9877
+ this.nextRequestAbortController = null;
9878
+ }
9878
9879
 
9879
9880
  if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
9880
9881
  options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
@@ -9882,7 +9883,7 @@ var StreamChat = /*#__PURE__*/function () {
9882
9883
  });
9883
9884
  }
9884
9885
 
9885
- return _objectSpread({
9886
+ return _objectSpread(_objectSpread({
9886
9887
  params: _objectSpread({
9887
9888
  user_id: this.userID,
9888
9889
  connection_id: this._getConnectionID(),
@@ -9892,7 +9893,9 @@ var StreamChat = /*#__PURE__*/function () {
9892
9893
  'stream-auth-type': this.getAuthType(),
9893
9894
  'X-Stream-Client': this.getUserAgent()
9894
9895
  }, options.headers)
9895
- }, options.config);
9896
+ }, signal ? {
9897
+ signal: signal
9898
+ } : {}), options.config);
9896
9899
  }
9897
9900
  }, {
9898
9901
  key: "_getToken",
@@ -11048,13 +11051,13 @@ var StreamChat = /*#__PURE__*/function () {
11048
11051
  }, {
11049
11052
  key: "deletePushProvider",
11050
11053
  value: function () {
11051
- var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref8) {
11054
+ var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref9) {
11052
11055
  var type, name;
11053
11056
  return _regeneratorRuntime__default['default'].wrap(function _callee76$(_context76) {
11054
11057
  while (1) {
11055
11058
  switch (_context76.prev = _context76.next) {
11056
11059
  case 0:
11057
- type = _ref8.type, name = _ref8.name;
11060
+ type = _ref9.type, name = _ref9.name;
11058
11061
  _context76.next = 3;
11059
11062
  return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
11060
11063
 
@@ -11111,6 +11114,15 @@ var StreamChat = /*#__PURE__*/function () {
11111
11114
 
11112
11115
  return listPushProviders;
11113
11116
  }()
11117
+ /**
11118
+ * creates an abort controller that will be used by the next HTTP Request.
11119
+ */
11120
+
11121
+ }, {
11122
+ key: "createAbortControllerForNextRequest",
11123
+ value: function createAbortControllerForNextRequest() {
11124
+ return this.nextRequestAbortController = new AbortController();
11125
+ }
11114
11126
  }], [{
11115
11127
  key: "getInstance",
11116
11128
  value: function getInstance(key, secretOrOptions, options) {