stream-chat 9.20.3 → 9.21.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.
@@ -5796,19 +5796,20 @@ var TextComposer = class {
5796
5796
  selection
5797
5797
  }) => {
5798
5798
  if (!this.enabled) return;
5799
+ const normalizedText = text.replace(/\r\n/g, "\n");
5799
5800
  const finalSelection = selection ?? this.selection;
5800
5801
  const { maxLengthOnEdit } = this.composer.config.text ?? {};
5801
5802
  const currentText = this.text;
5802
5803
  const textBeforeTrim = [
5803
5804
  currentText.slice(0, finalSelection.start),
5804
- text,
5805
+ normalizedText,
5805
5806
  currentText.slice(finalSelection.end)
5806
5807
  ].join("");
5807
5808
  const finalText = textBeforeTrim.slice(
5808
5809
  0,
5809
5810
  typeof maxLengthOnEdit === "number" ? maxLengthOnEdit : textBeforeTrim.length
5810
5811
  );
5811
- const expectedCursorPosition = finalSelection.start + text.length;
5812
+ const expectedCursorPosition = finalSelection.start + normalizedText.length;
5812
5813
  const cursorPosition = Math.min(expectedCursorPosition, finalText.length);
5813
5814
  await this.handleChange({
5814
5815
  text: finalText,
@@ -6842,12 +6843,9 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
6842
6843
  );
6843
6844
  this.initState({ composition: draft });
6844
6845
  } catch (error) {
6845
- this.client.notifications.add({
6846
- message: "Failed to get the draft",
6847
- origin: {
6848
- emitter: "MessageComposer",
6849
- context: { composer: this }
6850
- }
6846
+ this.client.logger("error", `messageComposer:getDraft`, {
6847
+ tags: ["channel", "messageComposer"],
6848
+ error
6851
6849
  });
6852
6850
  }
6853
6851
  };
@@ -8826,6 +8824,8 @@ var Channel = class {
8826
8824
  if (state.read) {
8827
8825
  for (const read of state.read) {
8828
8826
  this.state.read[read.user.id] = {
8827
+ last_delivered_at: read.last_delivered_at ? new Date(read.last_delivered_at) : void 0,
8828
+ last_delivered_message_id: read.last_delivered_message_id,
8829
8829
  last_read: new Date(read.last_read),
8830
8830
  last_read_message_id: read.last_read_message_id,
8831
8831
  unread_messages: read.unread_messages ?? 0,
@@ -13989,7 +13989,7 @@ var StreamChat = class _StreamChat {
13989
13989
  if (this.userAgent) {
13990
13990
  return this.userAgent;
13991
13991
  }
13992
- const version = "9.20.3";
13992
+ const version = "9.21.0";
13993
13993
  const clientBundle = "node-cjs";
13994
13994
  let userAgentString = "";
13995
13995
  if (this.sdkIdentifier) {
@@ -15137,6 +15137,20 @@ var StreamChat = class _StreamChat {
15137
15137
  deleteImage(url) {
15138
15138
  return this.delete(`${this.baseURL}/uploads/image`, { url });
15139
15139
  }
15140
+ /**
15141
+ * Send the mark delivered event for this user, only works if the `delivery_receipts` setting is enabled
15142
+ *
15143
+ * @param {MarkDeliveredOptions} data
15144
+ * @return {Promise<EventAPIResponse | void>} Description
15145
+ */
15146
+ async markChannelsDelivered(data) {
15147
+ const deliveryReceiptsEnabled = this.user?.privacy_settings?.delivery_receipts?.enabled;
15148
+ if (!deliveryReceiptsEnabled) return;
15149
+ return await this.post(
15150
+ this.baseURL + "/channels/delivered",
15151
+ data ?? {}
15152
+ );
15153
+ }
15140
15154
  };
15141
15155
 
15142
15156
  // src/events.ts
@@ -15163,6 +15177,7 @@ var EVENT_MAP = {
15163
15177
  "message.undeleted": true,
15164
15178
  "notification.added_to_channel": true,
15165
15179
  "notification.channel_deleted": true,
15180
+ "message.delivered": true,
15166
15181
  "notification.channel_mutes_updated": true,
15167
15182
  "notification.channel_truncated": true,
15168
15183
  "notification.invite_accepted": true,