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.
@@ -5632,19 +5632,20 @@ var TextComposer = class {
5632
5632
  selection
5633
5633
  }) => {
5634
5634
  if (!this.enabled) return;
5635
+ const normalizedText = text.replace(/\r\n/g, "\n");
5635
5636
  const finalSelection = selection ?? this.selection;
5636
5637
  const { maxLengthOnEdit } = this.composer.config.text ?? {};
5637
5638
  const currentText = this.text;
5638
5639
  const textBeforeTrim = [
5639
5640
  currentText.slice(0, finalSelection.start),
5640
- text,
5641
+ normalizedText,
5641
5642
  currentText.slice(finalSelection.end)
5642
5643
  ].join("");
5643
5644
  const finalText = textBeforeTrim.slice(
5644
5645
  0,
5645
5646
  typeof maxLengthOnEdit === "number" ? maxLengthOnEdit : textBeforeTrim.length
5646
5647
  );
5647
- const expectedCursorPosition = finalSelection.start + text.length;
5648
+ const expectedCursorPosition = finalSelection.start + normalizedText.length;
5648
5649
  const cursorPosition = Math.min(expectedCursorPosition, finalText.length);
5649
5650
  await this.handleChange({
5650
5651
  text: finalText,
@@ -6678,12 +6679,9 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
6678
6679
  );
6679
6680
  this.initState({ composition: draft });
6680
6681
  } catch (error) {
6681
- this.client.notifications.add({
6682
- message: "Failed to get the draft",
6683
- origin: {
6684
- emitter: "MessageComposer",
6685
- context: { composer: this }
6686
- }
6682
+ this.client.logger("error", `messageComposer:getDraft`, {
6683
+ tags: ["channel", "messageComposer"],
6684
+ error
6687
6685
  });
6688
6686
  }
6689
6687
  };
@@ -8662,6 +8660,8 @@ var Channel = class {
8662
8660
  if (state.read) {
8663
8661
  for (const read of state.read) {
8664
8662
  this.state.read[read.user.id] = {
8663
+ last_delivered_at: read.last_delivered_at ? new Date(read.last_delivered_at) : void 0,
8664
+ last_delivered_message_id: read.last_delivered_message_id,
8665
8665
  last_read: new Date(read.last_read),
8666
8666
  last_read_message_id: read.last_read_message_id,
8667
8667
  unread_messages: read.unread_messages ?? 0,
@@ -13825,7 +13825,7 @@ var StreamChat = class _StreamChat {
13825
13825
  if (this.userAgent) {
13826
13826
  return this.userAgent;
13827
13827
  }
13828
- const version = "9.20.3";
13828
+ const version = "9.21.0";
13829
13829
  const clientBundle = "browser-esm";
13830
13830
  let userAgentString = "";
13831
13831
  if (this.sdkIdentifier) {
@@ -14973,6 +14973,20 @@ var StreamChat = class _StreamChat {
14973
14973
  deleteImage(url) {
14974
14974
  return this.delete(`${this.baseURL}/uploads/image`, { url });
14975
14975
  }
14976
+ /**
14977
+ * Send the mark delivered event for this user, only works if the `delivery_receipts` setting is enabled
14978
+ *
14979
+ * @param {MarkDeliveredOptions} data
14980
+ * @return {Promise<EventAPIResponse | void>} Description
14981
+ */
14982
+ async markChannelsDelivered(data) {
14983
+ const deliveryReceiptsEnabled = this.user?.privacy_settings?.delivery_receipts?.enabled;
14984
+ if (!deliveryReceiptsEnabled) return;
14985
+ return await this.post(
14986
+ this.baseURL + "/channels/delivered",
14987
+ data ?? {}
14988
+ );
14989
+ }
14976
14990
  };
14977
14991
 
14978
14992
  // src/events.ts
@@ -14999,6 +15013,7 @@ var EVENT_MAP = {
14999
15013
  "message.undeleted": true,
15000
15014
  "notification.added_to_channel": true,
15001
15015
  "notification.channel_deleted": true,
15016
+ "message.delivered": true,
15002
15017
  "notification.channel_mutes_updated": true,
15003
15018
  "notification.channel_truncated": true,
15004
15019
  "notification.invite_accepted": true,