stream-chat 8.43.0 → 8.44.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
@@ -2285,7 +2285,7 @@ var Channel = /*#__PURE__*/function () {
2285
2285
  /**
2286
2286
  * queryMembers - Query Members
2287
2287
  *
2288
- * @param {UserFilters<StreamChatGenerics>} filterConditions object MongoDB style filters
2288
+ * @param {MemberFilters<StreamChatGenerics>} filterConditions object MongoDB style filters
2289
2289
  * @param {MemberSort<StreamChatGenerics>} [sort] Sort options, for instance [{created_at: -1}].
2290
2290
  * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}]
2291
2291
  * @param {{ limit?: number; offset?: number }} [options] Option object, {limit: 10, offset:10}
@@ -2822,7 +2822,7 @@ var Channel = /*#__PURE__*/function () {
2822
2822
  /**
2823
2823
  * addMembers - add members to the channel
2824
2824
  *
2825
- * @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
2825
+ * @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to add to the channel
2826
2826
  * @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification
2827
2827
  * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
2828
2828
  * @return {Promise<UpdateChannelAPIResponse<StreamChatGenerics>>} The server response
@@ -2951,7 +2951,7 @@ var Channel = /*#__PURE__*/function () {
2951
2951
  /**
2952
2952
  * inviteMembers - invite members to the channel
2953
2953
  *
2954
- * @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
2954
+ * @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to invite to the channel
2955
2955
  * @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification
2956
2956
  * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
2957
2957
  * @return {Promise<UpdateChannelAPIResponse<StreamChatGenerics>>} The server response
@@ -3364,7 +3364,7 @@ var Channel = /*#__PURE__*/function () {
3364
3364
  break;
3365
3365
  }
3366
3366
 
3367
- throw Error('A user_id is required for pinning a channel');
3367
+ throw new Error('A user_id is required for pinning a channel');
3368
3368
 
3369
3369
  case 5:
3370
3370
  _context27.next = 7;
@@ -3427,7 +3427,7 @@ var Channel = /*#__PURE__*/function () {
3427
3427
  break;
3428
3428
  }
3429
3429
 
3430
- throw Error('A user_id is required for unpinning a channel');
3430
+ throw new Error('A user_id is required for unpinning a channel');
3431
3431
 
3432
3432
  case 5:
3433
3433
  _context28.next = 7;
@@ -4764,14 +4764,17 @@ var Channel = /*#__PURE__*/function () {
4764
4764
  case 'member.added':
4765
4765
  case 'member.updated':
4766
4766
  if ((_event$member = event.member) !== null && _event$member !== void 0 && _event$member.user_id) {
4767
- channelState.members[event.member.user_id] = event.member;
4767
+ channelState.members = _objectSpread$a(_objectSpread$a({}, channelState.members), {}, _defineProperty({}, event.member.user_id, event.member));
4768
4768
  }
4769
4769
 
4770
4770
  break;
4771
4771
 
4772
4772
  case 'member.removed':
4773
4773
  if ((_event$user9 = event.user) !== null && _event$user9 !== void 0 && _event$user9.id) {
4774
- delete channelState.members[event.user.id];
4774
+ var newMembers = _objectSpread$a({}, channelState.members);
4775
+
4776
+ delete newMembers[event.user.id];
4777
+ channelState.members = newMembers;
4775
4778
  }
4776
4779
 
4777
4780
  break;
@@ -7291,6 +7294,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
7291
7294
  /**
7292
7295
  * Filter Types
7293
7296
  */
7297
+ // https://getstream.io/chat/docs/react/channel_member/#update-channel-members
7294
7298
 
7295
7299
  /**
7296
7300
  * Sort Types
@@ -8643,6 +8647,20 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
8643
8647
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8644
8648
  var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
8645
8649
  var MAX_QUERY_THREADS_LIMIT = 25;
8650
+ var THREAD_MANAGER_INITIAL_STATE = {
8651
+ active: false,
8652
+ isThreadOrderStale: false,
8653
+ threads: [],
8654
+ unreadThreadCount: 0,
8655
+ unseenThreadIds: [],
8656
+ lastConnectionDropAt: null,
8657
+ pagination: {
8658
+ isLoading: false,
8659
+ isLoadingNext: false,
8660
+ nextCursor: null
8661
+ },
8662
+ ready: false
8663
+ };
8646
8664
  var ThreadManager = /*#__PURE__*/function () {
8647
8665
  function ThreadManager(_ref) {
8648
8666
  var _this = this;
@@ -8659,6 +8677,10 @@ var ThreadManager = /*#__PURE__*/function () {
8659
8677
 
8660
8678
  _defineProperty(this, "threadsByIdGetterCache", void 0);
8661
8679
 
8680
+ _defineProperty(this, "resetState", function () {
8681
+ _this.state.next(THREAD_MANAGER_INITIAL_STATE);
8682
+ });
8683
+
8662
8684
  _defineProperty(this, "activate", function () {
8663
8685
  _this.state.partialNext({
8664
8686
  active: true
@@ -8683,6 +8705,8 @@ var ThreadManager = /*#__PURE__*/function () {
8683
8705
  _this.unsubscribeFunctions.add(_this.subscribeNewReplies());
8684
8706
 
8685
8707
  _this.unsubscribeFunctions.add(_this.subscribeRecoverAfterConnectionDrop());
8708
+
8709
+ _this.unsubscribeFunctions.add(_this.subscribeChannelDeleted());
8686
8710
  });
8687
8711
 
8688
8712
  _defineProperty(this, "subscribeUnreadThreadsCountChange", function () {
@@ -8718,6 +8742,23 @@ var ThreadManager = /*#__PURE__*/function () {
8718
8742
  };
8719
8743
  });
8720
8744
 
8745
+ _defineProperty(this, "subscribeChannelDeleted", function () {
8746
+ return _this.client.on('notification.channel_deleted', function (event) {
8747
+ var cid = event.cid;
8748
+
8749
+ var _this$state$getLatest = _this.state.getLatestValue(),
8750
+ threads = _this$state$getLatest.threads;
8751
+
8752
+ var newThreads = threads.filter(function (thread) {
8753
+ return thread.channel.cid !== cid;
8754
+ });
8755
+
8756
+ _this.state.partialNext({
8757
+ threads: newThreads
8758
+ });
8759
+ }).unsubscribe;
8760
+ });
8761
+
8721
8762
  _defineProperty(this, "subscribeManageThreadSubscriptions", function () {
8722
8763
  return _this.state.subscribeWithSelector(function (nextValue) {
8723
8764
  return {
@@ -8762,9 +8803,9 @@ var ThreadManager = /*#__PURE__*/function () {
8762
8803
  var parentId = (_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.parent_id;
8763
8804
  if (!parentId) return;
8764
8805
 
8765
- var _this$state$getLatest = _this.state.getLatestValue(),
8766
- unseenThreadIds = _this$state$getLatest.unseenThreadIds,
8767
- ready = _this$state$getLatest.ready;
8806
+ var _this$state$getLatest2 = _this.state.getLatestValue(),
8807
+ unseenThreadIds = _this$state$getLatest2.unseenThreadIds,
8808
+ ready = _this$state$getLatest2.ready;
8768
8809
 
8769
8810
  if (!ready) return;
8770
8811
 
@@ -8792,8 +8833,8 @@ var ThreadManager = /*#__PURE__*/function () {
8792
8833
  }).unsubscribe;
8793
8834
 
8794
8835
  var throttledHandleConnectionRecovered = throttle(function () {
8795
- var _this$state$getLatest2 = _this.state.getLatestValue(),
8796
- lastConnectionDropAt = _this$state$getLatest2.lastConnectionDropAt;
8836
+ var _this$state$getLatest3 = _this.state.getLatestValue(),
8837
+ lastConnectionDropAt = _this$state$getLatest3.lastConnectionDropAt;
8797
8838
 
8798
8839
  if (!lastConnectionDropAt) return;
8799
8840
 
@@ -8828,7 +8869,7 @@ var ThreadManager = /*#__PURE__*/function () {
8828
8869
  var _ref9,
8829
8870
  _ref9$force,
8830
8871
  force,
8831
- _this$state$getLatest3,
8872
+ _this$state$getLatest4,
8832
8873
  threads,
8833
8874
  unseenThreadIds,
8834
8875
  isThreadOrderStale,
@@ -8849,7 +8890,7 @@ var ThreadManager = /*#__PURE__*/function () {
8849
8890
  switch (_context.prev = _context.next) {
8850
8891
  case 0:
8851
8892
  _ref9 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref9$force = _ref9.force, force = _ref9$force === void 0 ? false : _ref9$force;
8852
- _this$state$getLatest3 = _this.state.getLatestValue(), threads = _this$state$getLatest3.threads, unseenThreadIds = _this$state$getLatest3.unseenThreadIds, isThreadOrderStale = _this$state$getLatest3.isThreadOrderStale, pagination = _this$state$getLatest3.pagination, ready = _this$state$getLatest3.ready;
8893
+ _this$state$getLatest4 = _this.state.getLatestValue(), threads = _this$state$getLatest4.threads, unseenThreadIds = _this$state$getLatest4.unseenThreadIds, isThreadOrderStale = _this$state$getLatest4.isThreadOrderStale, pagination = _this$state$getLatest4.pagination, ready = _this$state$getLatest4.ready;
8853
8894
 
8854
8895
  if (!pagination.isLoading) {
8855
8896
  _context.next = 4;
@@ -8963,7 +9004,7 @@ var ThreadManager = /*#__PURE__*/function () {
8963
9004
 
8964
9005
  _defineProperty(this, "loadNextPage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
8965
9006
  var options,
8966
- _this$state$getLatest4,
9007
+ _this$state$getLatest5,
8967
9008
  pagination,
8968
9009
  response,
8969
9010
  _args2 = arguments;
@@ -8973,7 +9014,7 @@ var ThreadManager = /*#__PURE__*/function () {
8973
9014
  switch (_context2.prev = _context2.next) {
8974
9015
  case 0:
8975
9016
  options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
8976
- _this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
9017
+ _this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination;
8977
9018
 
8978
9019
  if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
8979
9020
  _context2.next = 4;
@@ -9037,20 +9078,7 @@ var ThreadManager = /*#__PURE__*/function () {
9037
9078
  })));
9038
9079
 
9039
9080
  this.client = client;
9040
- this.state = new StateStore({
9041
- active: false,
9042
- isThreadOrderStale: false,
9043
- threads: [],
9044
- unreadThreadCount: 0,
9045
- unseenThreadIds: [],
9046
- lastConnectionDropAt: null,
9047
- pagination: {
9048
- isLoading: false,
9049
- isLoadingNext: false,
9050
- nextCursor: null
9051
- },
9052
- ready: false
9053
- });
9081
+ this.state = new StateStore(THREAD_MANAGER_INITIAL_STATE);
9054
9082
  this.threadsByIdGetterCache = {
9055
9083
  threads: [],
9056
9084
  threadsById: {}
@@ -9060,8 +9088,8 @@ var ThreadManager = /*#__PURE__*/function () {
9060
9088
  _createClass(ThreadManager, [{
9061
9089
  key: "threadsById",
9062
9090
  get: function get() {
9063
- var _this$state$getLatest5 = this.state.getLatestValue(),
9064
- threads = _this$state$getLatest5.threads;
9091
+ var _this$state$getLatest6 = this.state.getLatestValue(),
9092
+ threads = _this$state$getLatest6.threads;
9065
9093
 
9066
9094
  if (threads === this.threadsByIdGetterCache.threads) {
9067
9095
  return this.threadsByIdGetterCache.threadsById;
@@ -10409,14 +10437,17 @@ var StreamChat = /*#__PURE__*/function () {
10409
10437
 
10410
10438
  _this.activeChannels = {}; // reset client state
10411
10439
 
10412
- _this.state = new ClientState(); // reset token manager
10440
+ _this.state = new ClientState(); // reset thread manager
10441
+
10442
+ _this.threads.resetState(); // reset token manager
10443
+
10413
10444
 
10414
10445
  setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
10415
10446
  // close the WS connection
10416
10447
 
10417
10448
  return _context4.abrupt("return", closePromise);
10418
10449
 
10419
- case 11:
10450
+ case 12:
10420
10451
  case "end":
10421
10452
  return _context4.stop();
10422
10453
  }
@@ -14587,7 +14618,7 @@ var StreamChat = /*#__PURE__*/function () {
14587
14618
  }, {
14588
14619
  key: "getUserAgent",
14589
14620
  value: function getUserAgent() {
14590
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.43.0");
14621
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.44.0");
14591
14622
  }
14592
14623
  }, {
14593
14624
  key: "setUserAgent",
@@ -16906,5 +16937,5 @@ var BuiltinPermissions = {
16906
16937
  UseFrozenChannel: 'Send messages and reactions to frozen channels'
16907
16938
  };
16908
16939
 
16909
- export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Poll, PollManager, Segment, StableWSConnection, StateStore, StreamChat, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isVoteAnswer, logChatPromiseExecution, postInsights };
16940
+ export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Poll, PollManager, Segment, StableWSConnection, StateStore, StreamChat, THREAD_MANAGER_INITIAL_STATE, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isVoteAnswer, logChatPromiseExecution, postInsights };
16910
16941
  //# sourceMappingURL=index.es.js.map