stream-chat-react 10.22.0 → 10.22.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.
- package/dist/browser.full-bundle.js +43 -35
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Gallery/ModalGallery.d.ts.map +1 -1
- package/dist/components/Gallery/ModalGallery.js +11 -1
- package/dist/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.js +31 -32
- package/dist/css/v2/index.css +1 -1
- package/dist/css/v2/index.layout.css +1 -1
- package/dist/index.cjs.js +42 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/scss/v2/AttachmentList/AttachmentList-layout.scss +1 -0
- package/dist/scss/v2/vendor/react-image-gallery.scss +19 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -10886,7 +10886,16 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
10886
10886
|
|
|
10887
10887
|
var ImageGallery = /*@__PURE__*/getDefaultExportFromCjs(imageGallery.exports);
|
|
10888
10888
|
|
|
10889
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var
|
|
10889
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var onError = function (e) {
|
|
10890
|
+
// Prevent having alt attribute on img as the img takes the height of the alt text
|
|
10891
|
+
// instead of the CSS / element width & height when the CSS mask (fallback) is applied.
|
|
10892
|
+
e.target.alt = '';
|
|
10893
|
+
};
|
|
10894
|
+
var renderItem = function (_a) {
|
|
10895
|
+
var original = _a.original, originalAlt = _a.originalAlt;
|
|
10896
|
+
return (React__default["default"].createElement(BaseImage, { alt: originalAlt, className: 'image-gallery-image', onError: onError, src: original }));
|
|
10897
|
+
};
|
|
10898
|
+
var ModalGallery = function (props) {
|
|
10890
10899
|
var images = props.images, index = props.index;
|
|
10891
10900
|
var t = useTranslationContext('ModalGallery').t;
|
|
10892
10901
|
var formattedArray = React$2.useMemo(function () {
|
|
@@ -10899,7 +10908,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
10899
10908
|
};
|
|
10900
10909
|
});
|
|
10901
10910
|
}, [images]);
|
|
10902
|
-
return (React__default["default"].createElement(ImageGallery, { items: formattedArray, showIndex: true, showPlayButton: false, showThumbnails: false, startIndex: index }));
|
|
10911
|
+
return (React__default["default"].createElement(ImageGallery, { items: formattedArray, renderItem: renderItem, showIndex: true, showPlayButton: false, showThumbnails: false, startIndex: index }));
|
|
10903
10912
|
};
|
|
10904
10913
|
|
|
10905
10914
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var UnMemoizedGallery = function (props) {
|
|
@@ -47781,7 +47790,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
47781
47790
|
|
|
47782
47791
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
47783
47792
|
|
|
47784
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.22.
|
|
47793
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.22.2';
|
|
47785
47794
|
|
|
47786
47795
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
|
|
47787
47796
|
var _b, _c;
|
|
@@ -50586,11 +50595,14 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
50586
50595
|
};
|
|
50587
50596
|
}
|
|
50588
50597
|
|
|
50589
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var STATUSES_EXCLUDED_FROM_PREPEND =
|
|
50598
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var STATUSES_EXCLUDED_FROM_PREPEND = {
|
|
50599
|
+
failed: true,
|
|
50600
|
+
sending: true,
|
|
50601
|
+
};
|
|
50590
50602
|
function usePrependedMessagesCount(messages, hasDateSeparator) {
|
|
50591
50603
|
var firstRealMessageIndex = hasDateSeparator ? 1 : 0;
|
|
50592
|
-
var
|
|
50593
|
-
var
|
|
50604
|
+
var firstMessageOnFirstLoadedPage = React$2.useRef();
|
|
50605
|
+
var previousFirstMessageOnFirstLoadedPage = React$2.useRef();
|
|
50594
50606
|
var previousNumItemsPrepended = React$2.useRef(0);
|
|
50595
50607
|
var numItemsPrepended = React$2.useMemo(function () {
|
|
50596
50608
|
var _a, _b;
|
|
@@ -50598,47 +50610,43 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
50598
50610
|
previousNumItemsPrepended.current = 0;
|
|
50599
50611
|
return 0;
|
|
50600
50612
|
}
|
|
50601
|
-
var
|
|
50602
|
-
|
|
50603
|
-
|
|
50613
|
+
var currentFirstMessage = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex];
|
|
50614
|
+
var noNewMessages = (currentFirstMessage === null || currentFirstMessage === void 0 ? void 0 : currentFirstMessage.id) === ((_a = previousFirstMessageOnFirstLoadedPage.current) === null || _a === void 0 ? void 0 : _a.id);
|
|
50615
|
+
// This is possible only, when sending messages very quickly (basically single char messages submitted like a crazy) in empty channel (first page)
|
|
50616
|
+
// Optimistic UI update, when sending messages, can lead to a situation, when
|
|
50617
|
+
// the order of the messages changes for a moment. This can happen, when a user
|
|
50618
|
+
// sends multiple messages withing few milliseconds. E.g. we send a message A
|
|
50619
|
+
// then message B. At first we have message array with both messages of status "sending"
|
|
50620
|
+
// then response for message A is received with a new - later - created_at timestamp
|
|
50621
|
+
// this leads to rearrangement of 1.B ("sending"), 2.A ("received"). Still firstMessageOnFirstLoadedPage.current
|
|
50622
|
+
// points to message A, but now this message has index 1 => previousNumItemsPrepended.current === 1
|
|
50623
|
+
// That in turn leads to incorrect index calculation in VirtualizedMessageList trying to access a message
|
|
50624
|
+
// at non-existent index. Therefore, we ignore messages of status "sending" / "failed" in order they are
|
|
50625
|
+
// not considered as prepended messages.
|
|
50626
|
+
var firstMsgMovedAfterMessagesInExcludedStatus = (currentFirstMessage === null || currentFirstMessage === void 0 ? void 0 : currentFirstMessage.status) && STATUSES_EXCLUDED_FROM_PREPEND[currentFirstMessage.status];
|
|
50627
|
+
if (noNewMessages || firstMsgMovedAfterMessagesInExcludedStatus) {
|
|
50604
50628
|
return previousNumItemsPrepended.current;
|
|
50605
50629
|
}
|
|
50606
|
-
if (!
|
|
50607
|
-
|
|
50630
|
+
if (!firstMessageOnFirstLoadedPage.current) {
|
|
50631
|
+
firstMessageOnFirstLoadedPage.current = currentFirstMessage;
|
|
50608
50632
|
}
|
|
50609
|
-
|
|
50633
|
+
previousFirstMessageOnFirstLoadedPage.current = currentFirstMessage;
|
|
50610
50634
|
// if new messages were prepended, find out how many
|
|
50611
50635
|
// start with this number because there cannot be fewer prepended items than before
|
|
50612
|
-
var
|
|
50613
|
-
|
|
50614
|
-
|
|
50615
|
-
|
|
50616
|
-
|
|
50617
|
-
// then message B. At first we have message array with both messages of status "sending"
|
|
50618
|
-
// then response for message A is received with a new - later - created_at timestamp
|
|
50619
|
-
// this leads to rearrangement of 1.B ("sending"), 2.A ("received"). Still firstMessageId.current
|
|
50620
|
-
// points to message A, but now this message has index 1 => previousNumItemsPrepended.current === 1
|
|
50621
|
-
// That in turn leads to incorrect index calculation in VirtualizedMessageList trying to access a message
|
|
50622
|
-
// at non-existent index. Therefore, we ignore messages of status "sending" / "failed" in order they are
|
|
50623
|
-
// not considered as prepended messages.
|
|
50624
|
-
if (((_b = messages[i]) === null || _b === void 0 ? void 0 : _b.status) &&
|
|
50625
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50626
|
-
STATUSES_EXCLUDED_FROM_PREPEND.includes(messages[i].status) &&
|
|
50627
|
-
messages[i].id !== firstMessageId.current) {
|
|
50628
|
-
adjustPrependedMessageCount++;
|
|
50629
|
-
}
|
|
50630
|
-
if (messages[i].id === firstMessageId.current) {
|
|
50631
|
-
previousNumItemsPrepended.current = i - adjustPrependedMessageCount;
|
|
50632
|
-
return previousNumItemsPrepended.current;
|
|
50636
|
+
for (var prependedMessageCount = previousNumItemsPrepended.current; prependedMessageCount < messages.length; prependedMessageCount += 1) {
|
|
50637
|
+
var messageIsFirstOnFirstLoadedPage = messages[prependedMessageCount].id === ((_b = firstMessageOnFirstLoadedPage.current) === null || _b === void 0 ? void 0 : _b.id);
|
|
50638
|
+
if (messageIsFirstOnFirstLoadedPage) {
|
|
50639
|
+
previousNumItemsPrepended.current = prependedMessageCount;
|
|
50640
|
+
return prependedMessageCount;
|
|
50633
50641
|
}
|
|
50634
50642
|
}
|
|
50635
50643
|
// if no match has found, we have jumped - reset the prepended item count.
|
|
50636
|
-
|
|
50644
|
+
firstMessageOnFirstLoadedPage.current = currentFirstMessage;
|
|
50637
50645
|
previousNumItemsPrepended.current = 0;
|
|
50638
50646
|
return 0;
|
|
50639
50647
|
// TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
|
|
50640
50648
|
// that's why the second dependency is necessary
|
|
50641
|
-
}, [messages, messages === null || messages === void 0 ? void 0 : messages.length]);
|
|
50649
|
+
}, [firstRealMessageIndex, messages, messages === null || messages === void 0 ? void 0 : messages.length]);
|
|
50642
50650
|
return numItemsPrepended;
|
|
50643
50651
|
}
|
|
50644
50652
|
|