stream-chat 9.54.4 → 9.56.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.
@@ -9558,6 +9558,26 @@ var MessageReceiptsTracker = class {
9558
9558
  }
9559
9559
  };
9560
9560
 
9561
+ // src/utils/activeMemberCount.ts
9562
+ var withCarriedActiveMemberCount = ({
9563
+ next,
9564
+ previous
9565
+ }) => {
9566
+ const { active_member_count: nextActiveMemberCount, member_count: nextMemberCount } = next;
9567
+ const {
9568
+ active_member_count: previousActiveMemberCount,
9569
+ member_count: previousMemberCount
9570
+ } = previous ?? {};
9571
+ const hasOwnActiveMemberCount = typeof nextActiveMemberCount === "number";
9572
+ const hasPreviousActiveMemberCount = typeof previousActiveMemberCount === "number";
9573
+ if (hasOwnActiveMemberCount || !hasPreviousActiveMemberCount) return next;
9574
+ const memberCount = nextMemberCount ?? previousMemberCount;
9575
+ const delta = typeof nextMemberCount === "number" && typeof previousMemberCount === "number" ? nextMemberCount - previousMemberCount : 0;
9576
+ const shifted = Math.max(0, previousActiveMemberCount + delta);
9577
+ const carriedActiveMemberCount = typeof memberCount === "number" ? Math.min(shifted, memberCount) : shifted;
9578
+ return { ...next, active_member_count: carriedActiveMemberCount };
9579
+ };
9580
+
9561
9581
  // src/channel.ts
9562
9582
  var Channel = class {
9563
9583
  /**
@@ -9643,6 +9663,13 @@ var Channel = class {
9643
9663
  });
9644
9664
  this.cooldownTimer = new CooldownTimer({ channel: this });
9645
9665
  }
9666
+ get data() {
9667
+ return this._channelData;
9668
+ }
9669
+ set data(next) {
9670
+ const previous = this._channelData;
9671
+ this._channelData = next && withCarriedActiveMemberCount({ next, previous });
9672
+ }
9646
9673
  /**
9647
9674
  * getClient - Get the chat client for this channel. If client.disconnect() was called, this function will error
9648
9675
  *
@@ -15508,7 +15535,7 @@ var StreamChat = class _StreamChat {
15508
15535
  return this.userAgent;
15509
15536
  }
15510
15537
  if (!this.cachedUserAgent) {
15511
- const version = "9.54.4";
15538
+ const version = "9.56.0";
15512
15539
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
15513
15540
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
15514
15541
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -16567,10 +16594,17 @@ var StreamChat = class _StreamChat {
16567
16594
  * @return {<UpsertPushPreferencesResponse>}
16568
16595
  */
16569
16596
  async setPushPreferences(preferences) {
16570
- return await this.post(
16597
+ const result = await this.post(
16571
16598
  this.baseURL + "/push_preferences",
16572
16599
  { preferences }
16573
16600
  );
16601
+ const { user } = this;
16602
+ if (!user) return result;
16603
+ const updated = result.user_preferences[user.id];
16604
+ if (updated) {
16605
+ this.user = { ...user, push_preferences: updated };
16606
+ }
16607
+ return result;
16574
16608
  }
16575
16609
  /**
16576
16610
  * removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
@@ -18138,9 +18172,9 @@ var StreamChat = class _StreamChat {
18138
18172
  "Invalid delete user options. user must be one of [soft hard pruning]"
18139
18173
  );
18140
18174
  }
18141
- if (typeof options.conversations !== "undefined" && !["soft", "hard"].includes(options.conversations)) {
18175
+ if (typeof options.conversations !== "undefined" && !["soft", "hard", "keep"].includes(options.conversations)) {
18142
18176
  throw new Error(
18143
- "Invalid delete user options. conversations must be one of [soft hard]"
18177
+ "Invalid delete user options. conversations must be one of [soft hard keep]"
18144
18178
  );
18145
18179
  }
18146
18180
  if (typeof options.messages !== "undefined" && !["soft", "hard", "pruning"].includes(options.messages)) {