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.
@@ -2284,7 +2284,7 @@ var Channel = /*#__PURE__*/function () {
2284
2284
  /**
2285
2285
  * queryMembers - Query Members
2286
2286
  *
2287
- * @param {UserFilters<StreamChatGenerics>} filterConditions object MongoDB style filters
2287
+ * @param {MemberFilters<StreamChatGenerics>} filterConditions object MongoDB style filters
2288
2288
  * @param {MemberSort<StreamChatGenerics>} [sort] Sort options, for instance [{created_at: -1}].
2289
2289
  * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}]
2290
2290
  * @param {{ limit?: number; offset?: number }} [options] Option object, {limit: 10, offset:10}
@@ -2821,7 +2821,7 @@ var Channel = /*#__PURE__*/function () {
2821
2821
  /**
2822
2822
  * addMembers - add members to the channel
2823
2823
  *
2824
- * @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
2824
+ * @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to add to the channel
2825
2825
  * @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification
2826
2826
  * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
2827
2827
  * @return {Promise<UpdateChannelAPIResponse<StreamChatGenerics>>} The server response
@@ -2950,7 +2950,7 @@ var Channel = /*#__PURE__*/function () {
2950
2950
  /**
2951
2951
  * inviteMembers - invite members to the channel
2952
2952
  *
2953
- * @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
2953
+ * @param {string[] | Array<NewMemberPayload<StreamChatGenerics>>} members An array of members to invite to the channel
2954
2954
  * @param {Message<StreamChatGenerics>} [message] Optional message object for channel members notification
2955
2955
  * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
2956
2956
  * @return {Promise<UpdateChannelAPIResponse<StreamChatGenerics>>} The server response
@@ -3363,7 +3363,7 @@ var Channel = /*#__PURE__*/function () {
3363
3363
  break;
3364
3364
  }
3365
3365
 
3366
- throw Error('A user_id is required for pinning a channel');
3366
+ throw new Error('A user_id is required for pinning a channel');
3367
3367
 
3368
3368
  case 5:
3369
3369
  _context27.next = 7;
@@ -3426,7 +3426,7 @@ var Channel = /*#__PURE__*/function () {
3426
3426
  break;
3427
3427
  }
3428
3428
 
3429
- throw Error('A user_id is required for unpinning a channel');
3429
+ throw new Error('A user_id is required for unpinning a channel');
3430
3430
 
3431
3431
  case 5:
3432
3432
  _context28.next = 7;
@@ -4763,14 +4763,17 @@ var Channel = /*#__PURE__*/function () {
4763
4763
  case 'member.added':
4764
4764
  case 'member.updated':
4765
4765
  if ((_event$member = event.member) !== null && _event$member !== void 0 && _event$member.user_id) {
4766
- channelState.members[event.member.user_id] = event.member;
4766
+ channelState.members = _objectSpread$a(_objectSpread$a({}, channelState.members), {}, _defineProperty({}, event.member.user_id, event.member));
4767
4767
  }
4768
4768
 
4769
4769
  break;
4770
4770
 
4771
4771
  case 'member.removed':
4772
4772
  if ((_event$user9 = event.user) !== null && _event$user9 !== void 0 && _event$user9.id) {
4773
- delete channelState.members[event.user.id];
4773
+ var newMembers = _objectSpread$a({}, channelState.members);
4774
+
4775
+ delete newMembers[event.user.id];
4776
+ channelState.members = newMembers;
4774
4777
  }
4775
4778
 
4776
4779
  break;
@@ -7288,6 +7291,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
7288
7291
  /**
7289
7292
  * Filter Types
7290
7293
  */
7294
+ // https://getstream.io/chat/docs/react/channel_member/#update-channel-members
7291
7295
 
7292
7296
  /**
7293
7297
  * Sort Types
@@ -8640,6 +8644,20 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
8640
8644
  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; }
8641
8645
  var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
8642
8646
  var MAX_QUERY_THREADS_LIMIT = 25;
8647
+ var THREAD_MANAGER_INITIAL_STATE = {
8648
+ active: false,
8649
+ isThreadOrderStale: false,
8650
+ threads: [],
8651
+ unreadThreadCount: 0,
8652
+ unseenThreadIds: [],
8653
+ lastConnectionDropAt: null,
8654
+ pagination: {
8655
+ isLoading: false,
8656
+ isLoadingNext: false,
8657
+ nextCursor: null
8658
+ },
8659
+ ready: false
8660
+ };
8643
8661
  var ThreadManager = /*#__PURE__*/function () {
8644
8662
  function ThreadManager(_ref) {
8645
8663
  var _this = this;
@@ -8656,6 +8674,10 @@ var ThreadManager = /*#__PURE__*/function () {
8656
8674
 
8657
8675
  _defineProperty(this, "threadsByIdGetterCache", void 0);
8658
8676
 
8677
+ _defineProperty(this, "resetState", function () {
8678
+ _this.state.next(THREAD_MANAGER_INITIAL_STATE);
8679
+ });
8680
+
8659
8681
  _defineProperty(this, "activate", function () {
8660
8682
  _this.state.partialNext({
8661
8683
  active: true
@@ -8680,6 +8702,8 @@ var ThreadManager = /*#__PURE__*/function () {
8680
8702
  _this.unsubscribeFunctions.add(_this.subscribeNewReplies());
8681
8703
 
8682
8704
  _this.unsubscribeFunctions.add(_this.subscribeRecoverAfterConnectionDrop());
8705
+
8706
+ _this.unsubscribeFunctions.add(_this.subscribeChannelDeleted());
8683
8707
  });
8684
8708
 
8685
8709
  _defineProperty(this, "subscribeUnreadThreadsCountChange", function () {
@@ -8715,6 +8739,23 @@ var ThreadManager = /*#__PURE__*/function () {
8715
8739
  };
8716
8740
  });
8717
8741
 
8742
+ _defineProperty(this, "subscribeChannelDeleted", function () {
8743
+ return _this.client.on('notification.channel_deleted', function (event) {
8744
+ var cid = event.cid;
8745
+
8746
+ var _this$state$getLatest = _this.state.getLatestValue(),
8747
+ threads = _this$state$getLatest.threads;
8748
+
8749
+ var newThreads = threads.filter(function (thread) {
8750
+ return thread.channel.cid !== cid;
8751
+ });
8752
+
8753
+ _this.state.partialNext({
8754
+ threads: newThreads
8755
+ });
8756
+ }).unsubscribe;
8757
+ });
8758
+
8718
8759
  _defineProperty(this, "subscribeManageThreadSubscriptions", function () {
8719
8760
  return _this.state.subscribeWithSelector(function (nextValue) {
8720
8761
  return {
@@ -8759,9 +8800,9 @@ var ThreadManager = /*#__PURE__*/function () {
8759
8800
  var parentId = (_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.parent_id;
8760
8801
  if (!parentId) return;
8761
8802
 
8762
- var _this$state$getLatest = _this.state.getLatestValue(),
8763
- unseenThreadIds = _this$state$getLatest.unseenThreadIds,
8764
- ready = _this$state$getLatest.ready;
8803
+ var _this$state$getLatest2 = _this.state.getLatestValue(),
8804
+ unseenThreadIds = _this$state$getLatest2.unseenThreadIds,
8805
+ ready = _this$state$getLatest2.ready;
8765
8806
 
8766
8807
  if (!ready) return;
8767
8808
 
@@ -8789,8 +8830,8 @@ var ThreadManager = /*#__PURE__*/function () {
8789
8830
  }).unsubscribe;
8790
8831
 
8791
8832
  var throttledHandleConnectionRecovered = throttle(function () {
8792
- var _this$state$getLatest2 = _this.state.getLatestValue(),
8793
- lastConnectionDropAt = _this$state$getLatest2.lastConnectionDropAt;
8833
+ var _this$state$getLatest3 = _this.state.getLatestValue(),
8834
+ lastConnectionDropAt = _this$state$getLatest3.lastConnectionDropAt;
8794
8835
 
8795
8836
  if (!lastConnectionDropAt) return;
8796
8837
 
@@ -8825,7 +8866,7 @@ var ThreadManager = /*#__PURE__*/function () {
8825
8866
  var _ref9,
8826
8867
  _ref9$force,
8827
8868
  force,
8828
- _this$state$getLatest3,
8869
+ _this$state$getLatest4,
8829
8870
  threads,
8830
8871
  unseenThreadIds,
8831
8872
  isThreadOrderStale,
@@ -8846,7 +8887,7 @@ var ThreadManager = /*#__PURE__*/function () {
8846
8887
  switch (_context.prev = _context.next) {
8847
8888
  case 0:
8848
8889
  _ref9 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref9$force = _ref9.force, force = _ref9$force === void 0 ? false : _ref9$force;
8849
- _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;
8890
+ _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;
8850
8891
 
8851
8892
  if (!pagination.isLoading) {
8852
8893
  _context.next = 4;
@@ -8960,7 +9001,7 @@ var ThreadManager = /*#__PURE__*/function () {
8960
9001
 
8961
9002
  _defineProperty(this, "loadNextPage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
8962
9003
  var options,
8963
- _this$state$getLatest4,
9004
+ _this$state$getLatest5,
8964
9005
  pagination,
8965
9006
  response,
8966
9007
  _args2 = arguments;
@@ -8970,7 +9011,7 @@ var ThreadManager = /*#__PURE__*/function () {
8970
9011
  switch (_context2.prev = _context2.next) {
8971
9012
  case 0:
8972
9013
  options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
8973
- _this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
9014
+ _this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination;
8974
9015
 
8975
9016
  if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
8976
9017
  _context2.next = 4;
@@ -9034,20 +9075,7 @@ var ThreadManager = /*#__PURE__*/function () {
9034
9075
  })));
9035
9076
 
9036
9077
  this.client = client;
9037
- this.state = new StateStore({
9038
- active: false,
9039
- isThreadOrderStale: false,
9040
- threads: [],
9041
- unreadThreadCount: 0,
9042
- unseenThreadIds: [],
9043
- lastConnectionDropAt: null,
9044
- pagination: {
9045
- isLoading: false,
9046
- isLoadingNext: false,
9047
- nextCursor: null
9048
- },
9049
- ready: false
9050
- });
9078
+ this.state = new StateStore(THREAD_MANAGER_INITIAL_STATE);
9051
9079
  this.threadsByIdGetterCache = {
9052
9080
  threads: [],
9053
9081
  threadsById: {}
@@ -9057,8 +9085,8 @@ var ThreadManager = /*#__PURE__*/function () {
9057
9085
  _createClass(ThreadManager, [{
9058
9086
  key: "threadsById",
9059
9087
  get: function get() {
9060
- var _this$state$getLatest5 = this.state.getLatestValue(),
9061
- threads = _this$state$getLatest5.threads;
9088
+ var _this$state$getLatest6 = this.state.getLatestValue(),
9089
+ threads = _this$state$getLatest6.threads;
9062
9090
 
9063
9091
  if (threads === this.threadsByIdGetterCache.threads) {
9064
9092
  return this.threadsByIdGetterCache.threadsById;
@@ -10406,14 +10434,17 @@ var StreamChat = /*#__PURE__*/function () {
10406
10434
 
10407
10435
  _this.activeChannels = {}; // reset client state
10408
10436
 
10409
- _this.state = new ClientState(); // reset token manager
10437
+ _this.state = new ClientState(); // reset thread manager
10438
+
10439
+ _this.threads.resetState(); // reset token manager
10440
+
10410
10441
 
10411
10442
  setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
10412
10443
  // close the WS connection
10413
10444
 
10414
10445
  return _context4.abrupt("return", closePromise);
10415
10446
 
10416
- case 11:
10447
+ case 12:
10417
10448
  case "end":
10418
10449
  return _context4.stop();
10419
10450
  }
@@ -14584,7 +14615,7 @@ var StreamChat = /*#__PURE__*/function () {
14584
14615
  }, {
14585
14616
  key: "getUserAgent",
14586
14617
  value: function getUserAgent() {
14587
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.43.0");
14618
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.44.0");
14588
14619
  }
14589
14620
  }, {
14590
14621
  key: "setUserAgent",
@@ -16903,5 +16934,5 @@ var BuiltinPermissions = {
16903
16934
  UseFrozenChannel: 'Send messages and reactions to frozen channels'
16904
16935
  };
16905
16936
 
16906
- 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 };
16937
+ 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 };
16907
16938
  //# sourceMappingURL=browser.es.js.map