stream-chat 9.0.0 → 9.0.1

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.
@@ -2523,28 +2523,29 @@ var DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: false, hasPrev: false };
2523
2523
  var DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024;
2524
2524
  var API_MAX_FILES_ALLOWED_PER_MESSAGE = 10;
2525
2525
  var MAX_CHANNEL_MEMBER_COUNT_IN_CHANNEL_QUERY = 100;
2526
- var RESERVED_UPDATED_MESSAGE_FIELDS = [
2526
+ var RESERVED_UPDATED_MESSAGE_FIELDS = {
2527
2527
  // Dates should not be converted back to ISO strings as JS looses precision on them (milliseconds)
2528
- "created_at",
2529
- "deleted_at",
2530
- "pinned_at",
2531
- "updated_at",
2532
- "command",
2528
+ created_at: true,
2529
+ deleted_at: true,
2530
+ pinned_at: true,
2531
+ updated_at: true,
2532
+ command: true,
2533
2533
  // Back-end enriches these fields
2534
- "mentioned_users",
2535
- "quoted_message",
2534
+ mentioned_users: true,
2535
+ quoted_message: true,
2536
2536
  // Client-specific fields
2537
- "latest_reactions",
2538
- "own_reactions",
2539
- "reaction_counts",
2540
- "reply_count",
2537
+ latest_reactions: true,
2538
+ own_reactions: true,
2539
+ reaction_counts: true,
2540
+ reply_count: true,
2541
2541
  // Message text related fields that shouldn't be in update
2542
- "i18n",
2543
- "type",
2544
- "html",
2545
- "__html"
2546
- ];
2547
- var LOCAL_MESSAGE_FIELDS = ["error"];
2542
+ i18n: true,
2543
+ type: true,
2544
+ html: true,
2545
+ __html: true,
2546
+ user: true
2547
+ };
2548
+ var LOCAL_MESSAGE_FIELDS = { error: true };
2548
2549
 
2549
2550
  // src/utils.ts
2550
2551
  function logChatPromiseExecution(promise, name) {
@@ -2771,11 +2772,13 @@ var localMessageToNewMessagePayload = (localMessage) => {
2771
2772
  };
2772
2773
  };
2773
2774
  var toUpdatedMessagePayload = (message) => {
2775
+ const reservedKeys = {
2776
+ ...RESERVED_UPDATED_MESSAGE_FIELDS,
2777
+ ...LOCAL_MESSAGE_FIELDS
2778
+ };
2774
2779
  const messageFields = Object.fromEntries(
2775
2780
  Object.entries(message).filter(
2776
- ([key]) => ![...RESERVED_UPDATED_MESSAGE_FIELDS, ...LOCAL_MESSAGE_FIELDS].includes(
2777
- key
2778
- )
2781
+ ([key]) => !reservedKeys[key]
2779
2782
  )
2780
2783
  );
2781
2784
  return {
@@ -2783,8 +2786,7 @@ var toUpdatedMessagePayload = (message) => {
2783
2786
  pinned: !!message.pinned_at,
2784
2787
  mentioned_users: message.mentioned_users?.map(
2785
2788
  (user) => typeof user === "string" ? user : user.id
2786
- ),
2787
- user_id: message.user?.id ?? message.user_id
2789
+ )
2788
2790
  };
2789
2791
  };
2790
2792
  var findIndexInSortedArray = ({
@@ -13628,24 +13630,20 @@ var StreamChat = class _StreamChat {
13628
13630
  * updateMessage - Update the given message
13629
13631
  *
13630
13632
  * @param {Omit<MessageResponse, 'mentioned_users'> & { mentioned_users?: string[] }} message object, id needs to be specified
13631
- * @param {string | { id: string }} [userId]
13633
+ * @param {string | { id: string }} [partialUserOrUserId]
13632
13634
  * @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
13633
13635
  *
13634
13636
  * @return {{ message: LocalMessage | MessageResponse }} Response that includes the message
13635
13637
  */
13636
- async updateMessage(message, userId, options) {
13638
+ async updateMessage(message, partialUserOrUserId, options) {
13637
13639
  if (!message.id) {
13638
- throw Error("Please specify the message id when calling updateMessage");
13640
+ throw Error("Please specify the message.id when calling updateMessage");
13639
13641
  }
13640
13642
  const payload = toUpdatedMessagePayload(message);
13641
- if (userId != null) {
13642
- if (isString3(userId)) {
13643
- payload.user_id = userId;
13644
- } else {
13645
- payload.user = {
13646
- id: userId.id
13647
- };
13648
- }
13643
+ if (typeof partialUserOrUserId === "string") {
13644
+ payload.user_id = partialUserOrUserId;
13645
+ } else if (typeof partialUserOrUserId?.id === "string") {
13646
+ payload.user_id = partialUserOrUserId.id;
13649
13647
  }
13650
13648
  return await this.post(
13651
13649
  this.baseURL + `/messages/${encodeURIComponent(message.id)}`,
@@ -13668,13 +13666,15 @@ var StreamChat = class _StreamChat {
13668
13666
  *
13669
13667
  * @return {{ message: MessageResponse }} Response that includes the updated message
13670
13668
  */
13671
- async partialUpdateMessage(id, partialMessageObject, userId, options) {
13669
+ async partialUpdateMessage(id, partialMessageObject, partialUserOrUserId, options) {
13672
13670
  if (!id) {
13673
- throw Error("Please specify the message id when calling partialUpdateMessage");
13671
+ throw Error("Please specify the message.id when calling partialUpdateMessage");
13674
13672
  }
13675
- let user = userId;
13676
- if (userId != null && isString3(userId)) {
13677
- user = { id: userId };
13673
+ let user = void 0;
13674
+ if (typeof partialUserOrUserId === "string") {
13675
+ user = { id: partialUserOrUserId };
13676
+ } else if (typeof partialUserOrUserId?.id === "string") {
13677
+ user = { id: partialUserOrUserId.id };
13678
13678
  }
13679
13679
  return await this.put(
13680
13680
  this.baseURL + `/messages/${encodeURIComponent(id)}`,
@@ -13829,7 +13829,7 @@ var StreamChat = class _StreamChat {
13829
13829
  if (this.userAgent) {
13830
13830
  return this.userAgent;
13831
13831
  }
13832
- const version = "9.0.0";
13832
+ const version = "9.0.1";
13833
13833
  const clientBundle = "browser-cjs";
13834
13834
  let userAgentString = "";
13835
13835
  if (this.sdkIdentifier) {