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.
@@ -9366,6 +9366,26 @@ var MessageReceiptsTracker = class {
9366
9366
  }
9367
9367
  };
9368
9368
 
9369
+ // src/utils/activeMemberCount.ts
9370
+ var withCarriedActiveMemberCount = ({
9371
+ next,
9372
+ previous
9373
+ }) => {
9374
+ const { active_member_count: nextActiveMemberCount, member_count: nextMemberCount } = next;
9375
+ const {
9376
+ active_member_count: previousActiveMemberCount,
9377
+ member_count: previousMemberCount
9378
+ } = previous ?? {};
9379
+ const hasOwnActiveMemberCount = typeof nextActiveMemberCount === "number";
9380
+ const hasPreviousActiveMemberCount = typeof previousActiveMemberCount === "number";
9381
+ if (hasOwnActiveMemberCount || !hasPreviousActiveMemberCount) return next;
9382
+ const memberCount = nextMemberCount ?? previousMemberCount;
9383
+ const delta = typeof nextMemberCount === "number" && typeof previousMemberCount === "number" ? nextMemberCount - previousMemberCount : 0;
9384
+ const shifted = Math.max(0, previousActiveMemberCount + delta);
9385
+ const carriedActiveMemberCount = typeof memberCount === "number" ? Math.min(shifted, memberCount) : shifted;
9386
+ return { ...next, active_member_count: carriedActiveMemberCount };
9387
+ };
9388
+
9369
9389
  // src/channel.ts
9370
9390
  var Channel = class {
9371
9391
  /**
@@ -9451,6 +9471,13 @@ var Channel = class {
9451
9471
  });
9452
9472
  this.cooldownTimer = new CooldownTimer({ channel: this });
9453
9473
  }
9474
+ get data() {
9475
+ return this._channelData;
9476
+ }
9477
+ set data(next) {
9478
+ const previous = this._channelData;
9479
+ this._channelData = next && withCarriedActiveMemberCount({ next, previous });
9480
+ }
9454
9481
  /**
9455
9482
  * getClient - Get the chat client for this channel. If client.disconnect() was called, this function will error
9456
9483
  *
@@ -15316,7 +15343,7 @@ var StreamChat = class _StreamChat {
15316
15343
  return this.userAgent;
15317
15344
  }
15318
15345
  if (!this.cachedUserAgent) {
15319
- const version = "9.54.4";
15346
+ const version = "9.56.0";
15320
15347
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
15321
15348
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
15322
15349
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -16375,10 +16402,17 @@ var StreamChat = class _StreamChat {
16375
16402
  * @return {<UpsertPushPreferencesResponse>}
16376
16403
  */
16377
16404
  async setPushPreferences(preferences) {
16378
- return await this.post(
16405
+ const result = await this.post(
16379
16406
  this.baseURL + "/push_preferences",
16380
16407
  { preferences }
16381
16408
  );
16409
+ const { user } = this;
16410
+ if (!user) return result;
16411
+ const updated = result.user_preferences[user.id];
16412
+ if (updated) {
16413
+ this.user = { ...user, push_preferences: updated };
16414
+ }
16415
+ return result;
16382
16416
  }
16383
16417
  /**
16384
16418
  * removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
@@ -17946,9 +17980,9 @@ var StreamChat = class _StreamChat {
17946
17980
  "Invalid delete user options. user must be one of [soft hard pruning]"
17947
17981
  );
17948
17982
  }
17949
- if (typeof options.conversations !== "undefined" && !["soft", "hard"].includes(options.conversations)) {
17983
+ if (typeof options.conversations !== "undefined" && !["soft", "hard", "keep"].includes(options.conversations)) {
17950
17984
  throw new Error(
17951
- "Invalid delete user options. conversations must be one of [soft hard]"
17985
+ "Invalid delete user options. conversations must be one of [soft hard keep]"
17952
17986
  );
17953
17987
  }
17954
17988
  if (typeof options.messages !== "undefined" && !["soft", "hard", "pruning"].includes(options.messages)) {