stream-chat 8.14.1 → 8.14.2

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
@@ -3209,6 +3209,8 @@ var Channel = /*#__PURE__*/function () {
3209
3209
  */
3210
3210
  function () {
3211
3211
  var _query = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee32(options) {
3212
+ var _this$data4, _this$data5;
3213
+
3212
3214
  var messageSetToAddToIfDoesNotExist,
3213
3215
  queryURL,
3214
3216
  state,
@@ -3216,6 +3218,7 @@ var Channel = /*#__PURE__*/function () {
3216
3218
  tempChannelCid,
3217
3219
  _this$_initializeStat,
3218
3220
  messageSet,
3221
+ areCapabilitiesChanged,
3219
3222
  _args32 = arguments;
3220
3223
 
3221
3224
  return _regeneratorRuntime__default['default'].wrap(function _callee32$(_context32) {
@@ -3269,8 +3272,18 @@ var Channel = /*#__PURE__*/function () {
3269
3272
 
3270
3273
 
3271
3274
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
3275
+ areCapabilitiesChanged = _toConsumableArray__default['default'](state.channel.own_capabilities || []).sort().join() !== _toConsumableArray__default['default'](Array.isArray((_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.own_capabilities) ? (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.own_capabilities : []).sort().join();
3272
3276
  this.data = state.channel;
3273
3277
  this.offlineMode = false;
3278
+
3279
+ if (areCapabilitiesChanged) {
3280
+ this.getClient().dispatchEvent({
3281
+ type: 'capabilities.changed',
3282
+ cid: this.cid,
3283
+ own_capabilities: state.channel.own_capabilities
3284
+ });
3285
+ }
3286
+
3274
3287
  this.getClient().dispatchEvent({
3275
3288
  type: 'channels.queried',
3276
3289
  queriedChannels: {
@@ -3280,7 +3293,7 @@ var Channel = /*#__PURE__*/function () {
3280
3293
  });
3281
3294
  return _context32.abrupt("return", state);
3282
3295
 
3283
- case 15:
3296
+ case 17:
3284
3297
  case "end":
3285
3298
  return _context32.stop();
3286
3299
  }
@@ -3833,11 +3846,25 @@ var Channel = /*#__PURE__*/function () {
3833
3846
 
3834
3847
  case 'channel.updated':
3835
3848
  if (event.channel) {
3836
- var _event$channel$hidden, _event$channel2, _channel$data, _event$channel$own_ca, _event$channel3, _channel$data2;
3849
+ var _event$channel2, _channel$data, _event$channel$hidden, _event$channel3, _channel$data2, _event$channel$own_ca, _event$channel4, _channel$data3;
3850
+
3851
+ var isFrozenChanged = ((_event$channel2 = event.channel) === null || _event$channel2 === void 0 ? void 0 : _event$channel2.frozen) !== undefined && event.channel.frozen !== ((_channel$data = channel.data) === null || _channel$data === void 0 ? void 0 : _channel$data.frozen);
3852
+
3853
+ if (isFrozenChanged) {
3854
+ this.query({
3855
+ state: false,
3856
+ messages: {
3857
+ limit: 0
3858
+ },
3859
+ watchers: {
3860
+ limit: 0
3861
+ }
3862
+ });
3863
+ }
3837
3864
 
3838
3865
  channel.data = _objectSpread$5(_objectSpread$5({}, event.channel), {}, {
3839
- hidden: (_event$channel$hidden = (_event$channel2 = event.channel) === null || _event$channel2 === void 0 ? void 0 : _event$channel2.hidden) !== null && _event$channel$hidden !== void 0 ? _event$channel$hidden : (_channel$data = channel.data) === null || _channel$data === void 0 ? void 0 : _channel$data.hidden,
3840
- own_capabilities: (_event$channel$own_ca = (_event$channel3 = event.channel) === null || _event$channel3 === void 0 ? void 0 : _event$channel3.own_capabilities) !== null && _event$channel$own_ca !== void 0 ? _event$channel$own_ca : (_channel$data2 = channel.data) === null || _channel$data2 === void 0 ? void 0 : _channel$data2.own_capabilities
3866
+ hidden: (_event$channel$hidden = (_event$channel3 = event.channel) === null || _event$channel3 === void 0 ? void 0 : _event$channel3.hidden) !== null && _event$channel$hidden !== void 0 ? _event$channel$hidden : (_channel$data2 = channel.data) === null || _channel$data2 === void 0 ? void 0 : _channel$data2.hidden,
3867
+ own_capabilities: (_event$channel$own_ca = (_event$channel4 = event.channel) === null || _event$channel4 === void 0 ? void 0 : _event$channel4.own_capabilities) !== null && _event$channel$own_ca !== void 0 ? _event$channel$own_ca : (_channel$data3 = channel.data) === null || _channel$data3 === void 0 ? void 0 : _channel$data3.own_capabilities
3841
3868
  });
3842
3869
  }
3843
3870
 
@@ -3964,7 +3991,10 @@ var Channel = /*#__PURE__*/function () {
3964
3991
  this.state.pending_messages = state.pending_messages;
3965
3992
  }
3966
3993
 
3967
- this.state.watcher_count = state.watcher_count || 0; // convert the arrays into objects for easier syncing...
3994
+ if (state.watcher_count !== undefined) {
3995
+ this.state.watcher_count = state.watcher_count;
3996
+ } // convert the arrays into objects for easier syncing...
3997
+
3968
3998
 
3969
3999
  if (state.watchers) {
3970
4000
  var _iterator2 = _createForOfIteratorHelper$2(state.watchers),
@@ -10165,7 +10195,7 @@ var StreamChat = /*#__PURE__*/function () {
10165
10195
  }, {
10166
10196
  key: "getUserAgent",
10167
10197
  value: function getUserAgent() {
10168
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.14.1");
10198
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.14.2");
10169
10199
  }
10170
10200
  }, {
10171
10201
  key: "setUserAgent",
@@ -11558,7 +11588,8 @@ var EVENT_MAP = {
11558
11588
  'channels.queried': true,
11559
11589
  'connection.changed': true,
11560
11590
  'connection.recovered': true,
11561
- 'transport.changed': true
11591
+ 'transport.changed': true,
11592
+ 'capabilities.changed': true
11562
11593
  };
11563
11594
 
11564
11595
  var Allow = 'Allow';