From 6ea9ff0ca01782ec1b4ceffffb74d9fa9a2fdc1c Mon Sep 17 00:00:00 2001 From: MartinCupela <32706194+MartinCupela@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:21:28 +0200 Subject: [PATCH] feat(VirtualizedMessageList): allow to merge custom virtuoso components with the SDK defaults (#2140) Allow integrators to add only some custom virtuoso components via `VirtualizedMessageListProps['additionalVirtuosoProps']['components']` and the rest to be filled with the defaults provided by the SDK. --- .../DateSeparator/DateSeparator.tsx | 2 +- .../__tests__/DateSeparator.test.js | 4 + .../EventComponent/EventComponent.tsx | 2 +- .../__tests__/EventComponent.test.js | 1 + src/components/MessageList/MessageList.tsx | 8 +- .../MessageList/VirtualizedMessageList.tsx | 342 ++++++---------- .../VirtualizedMessageListComponents.tsx | 163 ++++++++ .../__tests__/VirtualizedMessageList.test.js | 2 +- .../VirtualizedMessageListComponents.test.js | 377 ++++++++++++++++++ ...tualizedMessageListComponents.test.js.snap | 183 +++++++++ .../MessageList/hooks/MessageList/index.ts | 4 + .../{ => MessageList}/useEnrichedMessages.ts | 10 +- .../useMessageListElements.tsx | 24 +- .../useMessageListScrollManager.ts | 6 +- .../useScrollLocationLogic.tsx | 4 +- .../hooks/VirtualizedMessageList/index.ts | 6 + .../useGiphyPreview.ts | 6 +- .../useMessageSetKey.ts | 33 ++ .../useNewMessageNotification.ts | 4 +- .../usePrependMessagesCount.ts | 4 +- .../useScrollToBottomOnNewMessage.ts | 58 +++ .../useShouldForceScrollToBottom.ts | 4 +- .../useMessageListScrollManager.test.js | 2 +- src/components/MessageList/hooks/index.ts | 14 +- 24 files changed, 997 insertions(+), 266 deletions(-) create mode 100644 src/components/MessageList/VirtualizedMessageListComponents.tsx create mode 100644 src/components/MessageList/__tests__/VirtualizedMessageListComponents.test.js create mode 100644 src/components/MessageList/__tests__/__snapshots__/VirtualizedMessageListComponents.test.js.snap create mode 100644 src/components/MessageList/hooks/MessageList/index.ts rename src/components/MessageList/hooks/{ => MessageList}/useEnrichedMessages.ts (87%) rename src/components/MessageList/hooks/{ => MessageList}/useMessageListElements.tsx (81%) rename src/components/MessageList/hooks/{ => MessageList}/useMessageListScrollManager.ts (93%) rename src/components/MessageList/hooks/{ => MessageList}/useScrollLocationLogic.tsx (95%) create mode 100644 src/components/MessageList/hooks/VirtualizedMessageList/index.ts rename src/components/MessageList/hooks/{ => VirtualizedMessageList}/useGiphyPreview.ts (80%) create mode 100644 src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts rename src/components/MessageList/hooks/{ => VirtualizedMessageList}/useNewMessageNotification.ts (92%) rename src/components/MessageList/hooks/{ => VirtualizedMessageList}/usePrependMessagesCount.ts (95%) create mode 100644 src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts rename src/components/MessageList/hooks/{ => VirtualizedMessageList}/useShouldForceScrollToBottom.ts (86%) diff --git a/src/components/DateSeparator/DateSeparator.tsx b/src/components/DateSeparator/DateSeparator.tsx index 6eae90c24..a01d8c09d 100644 --- a/src/components/DateSeparator/DateSeparator.tsx +++ b/src/components/DateSeparator/DateSeparator.tsx @@ -27,7 +27,7 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => { }); return ( -
{text}
diff --git a/src/components/EventComponent/__tests__/EventComponent.test.js b/src/components/EventComponent/__tests__/EventComponent.test.js index 7dd5a8853..5ddf99a0e 100644 --- a/src/components/EventComponent/__tests__/EventComponent.test.js +++ b/src/components/EventComponent/__tests__/EventComponent.test.js @@ -30,6 +30,7 @@ describe('EventComponent', () => { expect(tree).toMatchInlineSnapshot(`+ No chats here yet… +
+