stream-chat-react 10.7.4 → 10.7.6

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.
@@ -37104,7 +37104,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
37104
37104
  return (React__default["default"].createElement(ReactMarkdown$1, { allowedElements: allowedMarkups$1, components: rehypeComponents, rehypePlugins: rehypePlugins, remarkPlugins: [[remarkGfm, { singleTilde: false }]], skipHtml: true, transformLinkUri: function (uri) { return (uri.startsWith('app://') ? uri : uriTransformer$2(uri)); }, unwrapDisallowed: true }, newText));
37105
37105
  };
37106
37106
  function escapeRegExp(text) {
37107
- return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, '\\$&');
37107
+ return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
37108
37108
  }
37109
37109
  /**
37110
37110
  * @deprecated will be removed in the next major release
@@ -45791,6 +45791,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
45791
45791
  showCommandsList,
45792
45792
  showMentionsList,
45793
45793
  text,
45794
+ handleSubmit,
45794
45795
  ]);
45795
45796
  return messageInputContext;
45796
45797
  };
@@ -46707,7 +46708,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
46707
46708
  if (!(event.type === 'user.deleted')) return [3 /*break*/, 2];
46708
46709
  oldestID = (_l = (_k = (_j = channel.state) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.id;
46709
46710
  /**
46710
- * As the channel state is not normalized we re-fetch the channel data. Thus we avoid having to search for user references in the channel state.
46711
+ * As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
46711
46712
  */
46712
46713
  return [4 /*yield*/, channel.query({
46713
46714
  messages: { id_lt: oldestID, limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
@@ -46715,7 +46716,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
46715
46716
  })];
46716
46717
  case 1:
46717
46718
  /**
46718
- * As the channel state is not normalized we re-fetch the channel data. Thus we avoid having to search for user references in the channel state.
46719
+ * As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
46719
46720
  */
46720
46721
  _m.sent();
46721
46722
  _m.label = 2;
@@ -46946,9 +46947,10 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
46946
46947
  };
46947
46948
  var isUserResponseArray = function (output) { var _a; return ((_a = output[0]) === null || _a === void 0 ? void 0 : _a.id) != null; };
46948
46949
  var doSendMessage = function (message, customMessageData) { return __awaiter$1(void 0, void 0, void 0, function () {
46949
- var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, error_1, stringError, parsedError;
46950
- return __generator$1(this, function (_b) {
46951
- switch (_b.label) {
46950
+ var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, existingMessage, i, msg, responseTimestamp, existingMessageTimestamp, responseIsTheNewest, error_1, stringError, parsedError;
46951
+ var _b, _c;
46952
+ return __generator$1(this, function (_d) {
46953
+ switch (_d.label) {
46952
46954
  case 0:
46953
46955
  attachments = message.attachments, id = message.id, _a = message.mentioned_users, mentioned_users = _a === void 0 ? [] : _a, parent_id = message.parent_id, text = message.text;
46954
46956
  mentions = isUserResponseArray(mentioned_users)
@@ -46958,29 +46960,43 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
46958
46960
  })
46959
46961
  : mentioned_users;
46960
46962
  messageData = __assign$8({ attachments: attachments, id: id, mentioned_users: mentions, parent_id: parent_id, quoted_message_id: parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id) ? quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.id : undefined, text: text }, customMessageData);
46961
- _b.label = 1;
46963
+ _d.label = 1;
46962
46964
  case 1:
46963
- _b.trys.push([1, 6, , 7]);
46965
+ _d.trys.push([1, 6, , 7]);
46964
46966
  messageResponse = void 0;
46965
46967
  if (!doSendMessageRequest) return [3 /*break*/, 3];
46966
46968
  return [4 /*yield*/, doSendMessageRequest(channel.cid, messageData)];
46967
46969
  case 2:
46968
- messageResponse = _b.sent();
46970
+ messageResponse = _d.sent();
46969
46971
  return [3 /*break*/, 5];
46970
46972
  case 3: return [4 /*yield*/, channel.sendMessage(messageData)];
46971
46973
  case 4:
46972
- messageResponse = _b.sent();
46973
- _b.label = 5;
46974
+ messageResponse = _d.sent();
46975
+ _d.label = 5;
46974
46976
  case 5:
46975
- // replace it after send is completed
46976
- if (messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) {
46977
+ existingMessage = void 0;
46978
+ for (i = channel.state.messages.length - 1; i >= 0; i--) {
46979
+ msg = channel.state.messages[i];
46980
+ if (msg.id === messageData.id) {
46981
+ existingMessage = msg;
46982
+ break;
46983
+ }
46984
+ }
46985
+ responseTimestamp = new Date(((_b = messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) === null || _b === void 0 ? void 0 : _b.updated_at) || 0).getTime();
46986
+ existingMessageTimestamp = ((_c = existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.updated_at) === null || _c === void 0 ? void 0 : _c.getTime()) || 0;
46987
+ responseIsTheNewest = responseTimestamp > existingMessageTimestamp;
46988
+ // Replace the message payload after send is completed
46989
+ // We need to check for the newest message payload, because on slow network, the response can arrive later than WS events message.new, message.updated.
46990
+ // Always override existing message in status "sending"
46991
+ if ((messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) &&
46992
+ (responseIsTheNewest || (existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.status) === 'sending')) {
46977
46993
  updateMessage(__assign$8(__assign$8({}, messageResponse.message), { status: 'received' }));
46978
46994
  }
46979
46995
  if (quotedMessage && parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id))
46980
46996
  setQuotedMessage(undefined);
46981
46997
  return [3 /*break*/, 7];
46982
46998
  case 6:
46983
- error_1 = _b.sent();
46999
+ error_1 = _d.sent();
46984
47000
  stringError = JSON.stringify(error_1);
46985
47001
  parsedError = stringError ? JSON.parse(stringError) : {};
46986
47002
  updateMessage(__assign$8(__assign$8({}, message), { error: parsedError, errorStatusCode: parsedError.status || undefined, status: 'failed' }));
@@ -48378,7 +48394,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
48378
48394
 
48379
48395
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
48380
48396
 
48381
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.7.4';
48397
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.7.6';
48382
48398
 
48383
48399
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
48384
48400
  var _b, _c;