stream-chat 9.47.1 → 9.49.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.
@@ -7619,6 +7619,7 @@ var Thread = class extends WithSubscriptions {
7619
7619
  this.addUnsubscribeFunction(this.subscribeMarkThreadStale());
7620
7620
  this.addUnsubscribeFunction(this.subscribeNewReplies());
7621
7621
  this.addUnsubscribeFunction(this.subscribeRepliesRead());
7622
+ this.addUnsubscribeFunction(this.subscribeRepliesUnread());
7622
7623
  this.addUnsubscribeFunction(this.subscribeMessageDeleted());
7623
7624
  this.addUnsubscribeFunction(this.subscribeMessageUpdated());
7624
7625
  };
@@ -7660,6 +7661,26 @@ var Thread = class extends WithSubscriptions {
7660
7661
  }
7661
7662
  this.state.partialNext({ isStateStale: true });
7662
7663
  }).unsubscribe;
7664
+ this.subscribeRepliesUnread = () => this.client.on("notification.mark_unread", (event) => {
7665
+ if (!event.user || !event.created_at || !event.thread_id) return;
7666
+ if (event.thread_id !== this.id) return;
7667
+ const userId = event.user.id;
7668
+ const createdAt = event.created_at;
7669
+ const user = event.user;
7670
+ this.state.next((current) => ({
7671
+ ...current,
7672
+ read: {
7673
+ ...current.read,
7674
+ [userId]: {
7675
+ ...current.read[userId],
7676
+ lastReadAt: typeof event.last_read_at !== "undefined" ? new Date(event.last_read_at) : new Date(createdAt),
7677
+ user,
7678
+ firstUnreadMessageId: event.first_unread_message_id,
7679
+ unreadMessageCount: event.unread_messages ?? 0
7680
+ }
7681
+ }
7682
+ }));
7683
+ }).unsubscribe;
7663
7684
  this.subscribeNewReplies = () => this.client.on("message.new", (event) => {
7664
7685
  if (!this.client.userID || event.message?.parent_id !== this.id) {
7665
7686
  return;
@@ -12587,6 +12608,7 @@ var ThreadManager = class extends WithSubscriptions {
12587
12608
  const unsubscribeFunctions = [
12588
12609
  "health.check",
12589
12610
  "notification.mark_read",
12611
+ "notification.mark_unread",
12590
12612
  "notification.thread_message_new",
12591
12613
  "notification.channel_deleted"
12592
12614
  ].map(
@@ -14774,6 +14796,31 @@ var StreamChat = class _StreamChat {
14774
14796
  * @return {Promise<APIResponse>}
14775
14797
  */
14776
14798
  this.markAllRead = this.markChannelsRead;
14799
+ this.getUserAgent = () => {
14800
+ if (this.userAgent) {
14801
+ return this.userAgent;
14802
+ }
14803
+ if (!this.cachedUserAgent) {
14804
+ const version = "9.49.0";
14805
+ const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
14806
+ const { name: appName, version: appVersion } = this.appIdentifier ?? {};
14807
+ const { os, model: deviceModel } = this.deviceIdentifier ?? {};
14808
+ const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version}` : `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
14809
+ this.cachedUserAgent = [
14810
+ head,
14811
+ // reports the host app, the device OS, the device model, and the picked
14812
+ // exports bundle, each only when a value is present
14813
+ ...Object.entries({
14814
+ app: appName,
14815
+ app_version: appVersion,
14816
+ os,
14817
+ device_model: deviceModel,
14818
+ client_bundle: "node-cjs"
14819
+ }).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
14820
+ ].join("|");
14821
+ }
14822
+ return this.cachedUserAgent;
14823
+ };
14777
14824
  /**
14778
14825
  * _isUsingServerAuth - Returns true if we're using server side auth
14779
14826
  */
@@ -15226,6 +15273,13 @@ var StreamChat = class _StreamChat {
15226
15273
  delete this.activeChannels[cid];
15227
15274
  });
15228
15275
  }
15276
+ if (event.type === "notification.removed_from_channel" && event.cid) {
15277
+ const { cid } = event;
15278
+ this.activeChannels[cid]?._disconnect();
15279
+ postListenerCallbacks.push(() => {
15280
+ delete this.activeChannels[cid];
15281
+ });
15282
+ }
15229
15283
  return postListenerCallbacks;
15230
15284
  }
15231
15285
  _muteStatus(cid) {
@@ -16717,31 +16771,6 @@ var StreamChat = class _StreamChat {
16717
16771
  partialThreadObject
16718
16772
  );
16719
16773
  }
16720
- getUserAgent() {
16721
- if (this.userAgent) {
16722
- return this.userAgent;
16723
- }
16724
- const version = "9.47.1";
16725
- const clientBundle = "node-cjs";
16726
- let userAgentString = "";
16727
- if (this.sdkIdentifier) {
16728
- userAgentString = `stream-chat-${this.sdkIdentifier.name}-v${this.sdkIdentifier.version}-llc-v${version}`;
16729
- } else {
16730
- userAgentString = `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
16731
- }
16732
- const { os, model } = this.deviceIdentifier ?? {};
16733
- return [
16734
- // reports the device OS, if provided
16735
- ["os", os],
16736
- // reports the device model, if provided
16737
- ["device_model", model],
16738
- // reports which bundle is being picked from the exports
16739
- ["client_bundle", clientBundle]
16740
- ].reduce(
16741
- (withArguments, [key, value]) => value && value.length > 0 ? withArguments.concat(`|${key}=${value}`) : withArguments,
16742
- userAgentString
16743
- );
16744
- }
16745
16774
  /**
16746
16775
  * @deprecated use sdkIdentifier instead
16747
16776
  * @param userAgent