stream-chat-react 9.5.0 → 9.5.2

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.
@@ -5510,23 +5510,6 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
5510
5510
 
5511
5511
  var ReactPlayer = unwrapExports(lib$8);
5512
5512
 
5513
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
5514
-
5515
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};let nanoid = (size = 21) =>
5516
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
5517
- byte &= 63;
5518
- if (byte < 36) {
5519
- id += byte.toString(36);
5520
- } else if (byte < 62) {
5521
- id += (byte - 26).toString(36).toUpperCase();
5522
- } else if (byte > 62) {
5523
- id += '-';
5524
- } else {
5525
- id += '_';
5526
- }
5527
- return id
5528
- }, '');
5529
-
5530
5513
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var UnMemoizedAttachmentActions = function (props) {
5531
5514
  var actionHandler = props.actionHandler, actions = props.actions, id = props.id, text = props.text;
5532
5515
  var handleActionClick = function (event, name, value) {
@@ -11781,20 +11764,20 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11781
11764
  ? 'actions'
11782
11765
  : '';
11783
11766
  }
11784
- return (React__default['default'].createElement("div", { className: "str-chat__message-attachment str-chat__message-attachment--" + componentType + " str-chat__message-attachment--" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || '') + " str-chat__message-attachment--" + componentType + "--" + extra, key: (isGalleryAttachmentType(attachment) ? '' : (attachment === null || attachment === void 0 ? void 0 : attachment.id) || nanoid()) + "-" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || 'none') + " " }, children));
11767
+ return (React__default['default'].createElement("div", { className: "str-chat__message-attachment str-chat__message-attachment--" + componentType + " str-chat__message-attachment--" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || '') + " str-chat__message-attachment--" + componentType + "--" + extra }, children));
11785
11768
  };
11786
11769
  var renderAttachmentActions = function (props) {
11787
11770
  var _a;
11788
11771
  var actionHandler = props.actionHandler, attachment = props.attachment, _b = props.AttachmentActions, AttachmentActions$1 = _b === void 0 ? AttachmentActions : _b;
11789
11772
  if (!((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length))
11790
11773
  return null;
11791
- return (React__default['default'].createElement(AttachmentActions$1, __assign$2({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '', key: "key-actions-" + attachment.id, text: attachment.text || '' })));
11774
+ return (React__default['default'].createElement(AttachmentActions$1, __assign$2({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '', text: attachment.text || '' })));
11792
11775
  };
11793
11776
  var renderGallery = function (props) {
11794
11777
  var attachment = props.attachment, _a = props.Gallery, Gallery$1 = _a === void 0 ? Gallery : _a;
11795
11778
  return renderAttachmentWithinContainer({
11796
11779
  attachment: attachment,
11797
- children: React__default['default'].createElement(Gallery$1, { images: attachment.images || [], key: 'gallery' }),
11780
+ children: React__default['default'].createElement(Gallery$1, { images: attachment.images || [] }),
11798
11781
  componentType: 'gallery',
11799
11782
  });
11800
11783
  };
@@ -11803,7 +11786,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11803
11786
  if (attachment.actions && attachment.actions.length) {
11804
11787
  return renderAttachmentWithinContainer({
11805
11788
  attachment: attachment,
11806
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
11789
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
11807
11790
  React__default['default'].createElement(Image, __assign$2({}, attachment)),
11808
11791
  renderAttachmentActions(props))),
11809
11792
  componentType: 'image',
@@ -11811,7 +11794,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11811
11794
  }
11812
11795
  return renderAttachmentWithinContainer({
11813
11796
  attachment: attachment,
11814
- children: React__default['default'].createElement(Image, __assign$2({}, attachment, { key: "key-image-" + attachment.id })),
11797
+ children: React__default['default'].createElement(Image, __assign$2({}, attachment)),
11815
11798
  componentType: 'image',
11816
11799
  });
11817
11800
  };
@@ -11820,15 +11803,15 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11820
11803
  if (attachment.actions && attachment.actions.length) {
11821
11804
  return renderAttachmentWithinContainer({
11822
11805
  attachment: attachment,
11823
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
11824
- React__default['default'].createElement(Card, __assign$2({}, attachment, { key: "key-card-" + attachment.id })),
11806
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
11807
+ React__default['default'].createElement(Card, __assign$2({}, attachment)),
11825
11808
  renderAttachmentActions(props))),
11826
11809
  componentType: 'card',
11827
11810
  });
11828
11811
  }
11829
11812
  return renderAttachmentWithinContainer({
11830
11813
  attachment: attachment,
11831
- children: React__default['default'].createElement(Card, __assign$2({}, attachment, { key: "key-card-" + attachment.id })),
11814
+ children: React__default['default'].createElement(Card, __assign$2({}, attachment)),
11832
11815
  componentType: 'card',
11833
11816
  });
11834
11817
  };
@@ -11838,7 +11821,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11838
11821
  return null;
11839
11822
  return renderAttachmentWithinContainer({
11840
11823
  attachment: attachment,
11841
- children: React__default['default'].createElement(File, { attachment: attachment, key: "key-file-" + attachment.id }),
11824
+ children: React__default['default'].createElement(File, { attachment: attachment }),
11842
11825
  componentType: 'file',
11843
11826
  });
11844
11827
  };
@@ -11846,7 +11829,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11846
11829
  var attachment = props.attachment, _a = props.Audio, Audio$1 = _a === void 0 ? Audio : _a;
11847
11830
  return renderAttachmentWithinContainer({
11848
11831
  attachment: attachment,
11849
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-video-" + attachment.id },
11832
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
11850
11833
  React__default['default'].createElement(Audio$1, { og: attachment }))),
11851
11834
  componentType: 'audio',
11852
11835
  });
@@ -11857,7 +11840,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11857
11840
  if ((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length) {
11858
11841
  return renderAttachmentWithinContainer({
11859
11842
  attachment: attachment,
11860
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media', key: "key-video-" + attachment.id },
11843
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media' },
11861
11844
  React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
11862
11845
  React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' })),
11863
11846
  renderAttachmentActions(props))),
@@ -11866,7 +11849,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11866
11849
  }
11867
11850
  return renderAttachmentWithinContainer({
11868
11851
  attachment: attachment,
11869
- children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper', key: "key-video-" + attachment.id },
11852
+ children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
11870
11853
  React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' }))),
11871
11854
  componentType: 'media',
11872
11855
  });
@@ -11889,7 +11872,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11889
11872
  })), [
11890
11873
  gallery,
11891
11874
  ]) : attachments;
11892
- return (React__default['default'].createElement(React__default['default'].Fragment, null, newAttachments.map(function (attachment) {
11875
+ var getContent = function (attachment) {
11893
11876
  if (isGalleryAttachmentType(attachment)) {
11894
11877
  return renderGallery(__assign$2(__assign$2({}, rest), { attachment: attachment }));
11895
11878
  }
@@ -11906,7 +11889,8 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
11906
11889
  return renderMedia(__assign$2(__assign$2({}, rest), { attachment: attachment }));
11907
11890
  }
11908
11891
  return renderCard(__assign$2(__assign$2({}, rest), { attachment: attachment }));
11909
- })));
11892
+ };
11893
+ return (React__default['default'].createElement(React__default['default'].Fragment, null, newAttachments.map(function (attachment, i) { return (React__default['default'].createElement(React__default['default'].Fragment, { key: i }, getContent(attachment))); })));
11910
11894
  };
11911
11895
 
11912
11896
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
@@ -13562,6 +13546,23 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
13562
13546
  var linkifyjs = linkify;
13563
13547
  var linkifyjs_1 = linkifyjs.find;
13564
13548
 
13549
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
13550
+
13551
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};let nanoid = (size = 21) =>
13552
+ crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
13553
+ byte &= 63;
13554
+ if (byte < 36) {
13555
+ id += byte.toString(36);
13556
+ } else if (byte < 62) {
13557
+ id += (byte - 26).toString(36).toUpperCase();
13558
+ } else if (byte > 62) {
13559
+ id += '-';
13560
+ } else {
13561
+ id += '_';
13562
+ }
13563
+ return id
13564
+ }, '');
13565
+
13565
13566
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function escapeStringRegexp(string) {
13566
13567
  if (typeof string !== 'string') {
13567
13568
  throw new TypeError('Expected a string');
@@ -42124,6 +42125,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
42124
42125
  });
42125
42126
  });
42126
42127
  };
42128
+ var clearHighlightedMessageTimeoutId = React.useRef(null);
42127
42129
  var jumpToMessage = function (messageId, messageLimit) {
42128
42130
  if (messageLimit === void 0) { messageLimit = 100; }
42129
42131
  return __awaiter$1(void 0, void 0, void 0, function () {
@@ -42143,7 +42145,11 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
42143
42145
  highlightedMessageId: messageId,
42144
42146
  type: 'jumpToMessageFinished',
42145
42147
  });
42146
- setTimeout(function () {
42148
+ if (clearHighlightedMessageTimeoutId.current) {
42149
+ clearTimeout(clearHighlightedMessageTimeoutId.current);
42150
+ }
42151
+ clearHighlightedMessageTimeoutId.current = setTimeout(function () {
42152
+ clearHighlightedMessageTimeoutId.current = null;
42147
42153
  dispatch({ type: 'clearHighlightedMessage' });
42148
42154
  }, 500);
42149
42155
  return [2 /*return*/];
@@ -43378,7 +43384,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
43378
43384
 
43379
43385
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
43380
43386
 
43381
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.5.0';
43387
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.5.2';
43382
43388
 
43383
43389
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
43384
43390
  var _b, _c;
@@ -46530,16 +46536,17 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
46530
46536
  }
46531
46537
 
46532
46538
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function usePrependedMessagesCount(messages, hasDateSeparator) {
46533
- var _a;
46534
46539
  var firstRealMessageIndex = hasDateSeparator ? 1 : 0;
46535
- var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
46536
- var firstMessageId = React.useRef(currentFirstMessageId);
46537
- var earliestMessageId = React.useRef(currentFirstMessageId);
46540
+ var firstMessageId = React.useRef();
46541
+ var earliestMessageId = React.useRef();
46538
46542
  var previousNumItemsPrepended = React.useRef(0);
46539
46543
  var numItemsPrepended = React.useMemo(function () {
46544
+ var _a;
46540
46545
  if (!messages || !messages.length) {
46546
+ previousNumItemsPrepended.current = 0;
46541
46547
  return 0;
46542
46548
  }
46549
+ var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
46543
46550
  // if no new messages were prepended, return early (same amount as before)
46544
46551
  if (currentFirstMessageId === earliestMessageId.current) {
46545
46552
  return previousNumItemsPrepended.current;
@@ -46556,8 +46563,9 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
46556
46563
  return i;
46557
46564
  }
46558
46565
  }
46559
- // if no match has found, we have jumped
46566
+ // if no match has found, we have jumped - reset the prepend item count.
46560
46567
  firstMessageId.current = currentFirstMessageId;
46568
+ previousNumItemsPrepended.current = 0;
46561
46569
  return 0;
46562
46570
  // TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
46563
46571
  // that's why the second dependency is necessary