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.
@@ -5811,19 +5811,20 @@ var TextComposer = class {
5811
5811
  selection
5812
5812
  }) => {
5813
5813
  if (!this.enabled) return;
5814
+ const normalizedText = text.replace(/\r\n/g, "\n");
5814
5815
  const finalSelection = selection ?? this.selection;
5815
5816
  const { maxLengthOnEdit } = this.composer.config.text ?? {};
5816
5817
  const currentText = this.text;
5817
5818
  const textBeforeTrim = [
5818
5819
  currentText.slice(0, finalSelection.start),
5819
- text,
5820
+ normalizedText,
5820
5821
  currentText.slice(finalSelection.end)
5821
5822
  ].join("");
5822
5823
  const finalText = textBeforeTrim.slice(
5823
5824
  0,
5824
5825
  typeof maxLengthOnEdit === "number" ? maxLengthOnEdit : textBeforeTrim.length
5825
5826
  );
5826
- const expectedCursorPosition = finalSelection.start + text.length;
5827
+ const expectedCursorPosition = finalSelection.start + normalizedText.length;
5827
5828
  const cursorPosition = Math.min(expectedCursorPosition, finalText.length);
5828
5829
  await this.handleChange({
5829
5830
  text: finalText,
@@ -6857,12 +6858,9 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
6857
6858
  );
6858
6859
  this.initState({ composition: draft });
6859
6860
  } catch (error) {
6860
- this.client.notifications.add({
6861
- message: "Failed to get the draft",
6862
- origin: {
6863
- emitter: "MessageComposer",
6864
- context: { composer: this }
6865
- }
6861
+ this.client.logger("error", `messageComposer:getDraft`, {
6862
+ tags: ["channel", "messageComposer"],
6863
+ error
6866
6864
  });
6867
6865
  }
6868
6866
  };
@@ -8841,6 +8839,8 @@ var Channel = class {
8841
8839
  if (state.read) {
8842
8840
  for (const read of state.read) {
8843
8841
  this.state.read[read.user.id] = {
8842
+ last_delivered_at: read.last_delivered_at ? new Date(read.last_delivered_at) : void 0,
8843
+ last_delivered_message_id: read.last_delivered_message_id,
8844
8844
  last_read: new Date(read.last_read),
8845
8845
  last_read_message_id: read.last_read_message_id,
8846
8846
  unread_messages: read.unread_messages ?? 0,
@@ -14004,7 +14004,7 @@ var StreamChat = class _StreamChat {
14004
14004
  if (this.userAgent) {
14005
14005
  return this.userAgent;
14006
14006
  }
14007
- const version = "9.20.3";
14007
+ const version = "9.21.0";
14008
14008
  const clientBundle = "browser-cjs";
14009
14009
  let userAgentString = "";
14010
14010
  if (this.sdkIdentifier) {
@@ -15152,6 +15152,20 @@ var StreamChat = class _StreamChat {
15152
15152
  deleteImage(url) {
15153
15153
  return this.delete(`${this.baseURL}/uploads/image`, { url });
15154
15154
  }
15155
+ /**
15156
+ * Send the mark delivered event for this user, only works if the `delivery_receipts` setting is enabled
15157
+ *
15158
+ * @param {MarkDeliveredOptions} data
15159
+ * @return {Promise<EventAPIResponse | void>} Description
15160
+ */
15161
+ async markChannelsDelivered(data) {
15162
+ const deliveryReceiptsEnabled = this.user?.privacy_settings?.delivery_receipts?.enabled;
15163
+ if (!deliveryReceiptsEnabled) return;
15164
+ return await this.post(
15165
+ this.baseURL + "/channels/delivered",
15166
+ data ?? {}
15167
+ );
15168
+ }
15155
15169
  };
15156
15170
 
15157
15171
  // src/events.ts
@@ -15178,6 +15192,7 @@ var EVENT_MAP = {
15178
15192
  "message.undeleted": true,
15179
15193
  "notification.added_to_channel": true,
15180
15194
  "notification.channel_deleted": true,
15195
+ "message.delivered": true,
15181
15196
  "notification.channel_mutes_updated": true,
15182
15197
  "notification.channel_truncated": true,
15183
15198
  "notification.invite_accepted": true,