Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: initial message load issues #2292

Merged
merged 7 commits into from
Feb 23, 2024
Merged

Conversation

myandrienko
Copy link
Contributor

@myandrienko myandrienko commented Feb 22, 2024

🎯 Goal

This PR covers a range of issues that originate from incorrect initialization of message list state. All the cases are covered below.

🛠 Implementation details

ChannelList, Channel, MessageList, VirtualizedMessageList not respecting the message limits

We have several default limits listed in the limit.ts file. However they were not always respected:

  1. MessageList, VirtualizedMessageList didn't use DEFAULT_NEXT_CHANNEL_PAGE_SIZE and defaulted to the hard-coded message limit of 100.
  2. Channel didn't use DEFAULT_INITIAL_CHANNEL_PAGE_SIZE when fetching the first page of messages.
  3. ChannelList didn't use DEFAULT_INITIAL_CHANNEL_PAGE_SIZE as the message limit per channel when fetching channels.

This is now fixed.

False-negative hasMore when messages are fetched by ChannelList

We have two main ways to initialize the message list: it can be initialized by the Channel component; or it can be initialized by the ChannelList component (using usePaginatedChannels hook). If the message list is initialized by the ChannelList, the Channel component will not try to query the channel, and will use messages fetched by the ChannelList instead.

The problem here is that to determine if the channel has more messages to load, we used to compare the number of messages currently in the channel with the limit set on the Channel. But since it was not the Channel but the ChannelList that fetched the messages, this check makes no sense: ChannelList has its own separate limits.

Consider this example:

const App = () => (
  <Chat client={chatClient}>
    <ChannelList options={{ message_limit: 5 }} />
    <Channel channelQueryOptions={{ members: { limit: 10 } }}>
      {/* ... */}
    </Channel>
  </Chat>
);

The Channel component will compare the number of messages fetched by the ChannelList (5) with its own limit (10) and determine that the channel has no more messages.

This is fixed by always setting hasMore to false in channel if it was not the Channel component that fetched the messages. In the worst case we'll just make one redundant query.

The "tall window" problem

In case the message container is very tall, or the message limit for the initial load is very small, we can run into a situation when the first page of messages is not long enough to trigger overflow in the message list. Without overflow, scroll events don't fire, so the next page of messages is never fetched.

This is not usually a problem in the VirtualizedMessageList, since it will immediately load the next page once in this case. However, the MessageList didn't have this logic in place. It is now added (by invoking the scrollListener once on mount).

Note: both VirtualizedMessageList and MessageList will only try loading the next page once if the first page of messages is not long enough to cause overflow. A better solution would be to keep loading pages until there's overflow or there is no more pages. This solution is not currently possible to implement in VirtualizedMessageList, so for the sake of consistency I didn't implement it MessageList (event though it is possible).

In most cases this not an issue, since our default page size is 100 messages which is enough to fill even very tall containers.

Comment on lines +370 to +378
const channelQueryOptions: ChannelQueryOptions<StreamChatGenerics> & {
messages: { limit: number };
} = useMemo(
() =>
defaultsDeep(propChannelQueryOptions, {
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE },
}),
[propChannelQueryOptions],
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DEFAULT_INITIAL_CHANNEL_PAGE_SIZE when loading the first page of messages.

Comment on lines -586 to +604
hasMore: hasMoreMessagesProbably(
channel.state.messages.length,
channelQueryOptions?.messages?.limit ?? DEFAULT_INITIAL_CHANNEL_PAGE_SIZE,
),
hasMore:
channelInitializedExternally ||
hasMoreMessagesProbably(
channel.state.messages.length,
channelQueryOptions.messages.limit,
),
Copy link
Contributor Author

@myandrienko myandrienko Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it wasn't the Channel component itself that loaded the first page of messages, don't trust the message count to determine if there's more messages to load, since the function that loaded messages could have totally different limits.

@@ -79,6 +80,7 @@ export const usePaginatedChannels = <

const newOptions = {
limit: options?.limit ?? MAX_QUERY_CHANNELS_LIMIT,
message_limit: options?.message_limit ?? DEFAULT_INITIAL_CHANNEL_PAGE_SIZE,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DEFAULT_INITIAL_CHANNEL_PAGE_SIZE to limit the number of messages when loading channel list.


return () => {
scrollElement.removeEventListener('scroll', scrollListener, useCapture);
scrollElement.removeEventListener('resize', scrollListener, useCapture);
};
}, [initialLoad, scrollListener, useCapture]);
}, [initialLoad, useCapture]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent this effect from firing excessively. Note that scrollListener is now a ref, so it always has access to the latest props.

@@ -68,7 +69,7 @@ const MessageListWithContext = <
headerPosition,
read,
renderMessages = defaultRenderMessages,
messageLimit = 100,
messageLimit = DEFAULT_NEXT_CHANNEL_PAGE_SIZE,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove hard-coded limit for message page size.

@@ -184,7 +185,7 @@ const VirtualizedMessageListWithContext = <
loadMoreNewer,
Message: MessageUIComponentFromProps,
messageActions,
messageLimit = 100,
messageLimit = DEFAULT_NEXT_CHANNEL_PAGE_SIZE,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove hard-coded limit for message page size.

Copy link

github-actions bot commented Feb 22, 2024

Size Change: +30.1 kB (+2%)

Total Size: 1.79 MB

Filename Size Change
./dist/browser.full-bundle.js 716 kB +14.5 kB (+2%)
./dist/browser.full-bundle.min.js 388 kB +3.55 kB (+1%)
./dist/components/Channel/Channel.js 9.41 kB +42 B (0%)
./dist/components/ChannelList/hooks/usePaginatedChannels.js 1.59 kB +67 B (+4%)
./dist/components/Emojis/index.cjs.js 1.87 kB +1 B (0%)
./dist/components/InfiniteScrollPaginator/InfiniteScroll.js 1.45 kB +1 B (0%)
./dist/components/MessageList/MessageList.js 3.27 kB +42 B (+1%)
./dist/components/MessageList/VirtualizedMessageList.js 4.4 kB +47 B (+1%)
./dist/index.cjs.js 24.5 kB +67 B (0%)
./dist/Window-ee911206.js 0 B -330 kB (removed) 🏆
./dist/Window-7d524c3b.js 341 kB +341 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
./dist/components/Attachment/attachment-sizing.js 1.08 kB
./dist/components/Attachment/Attachment.js 1.04 kB
./dist/components/Attachment/AttachmentActions.js 524 B
./dist/components/Attachment/AttachmentContainer.js 2.13 kB
./dist/components/Attachment/Audio.js 1.64 kB
./dist/components/Attachment/Card.js 1.76 kB
./dist/components/Attachment/DownloadButton.js 259 B
./dist/components/Attachment/FileAttachment.js 555 B
./dist/components/Attachment/FileSizeIndicator.js 240 B
./dist/components/Attachment/hooks/useAudioController.js 653 B
./dist/components/Attachment/icons.js 573 B
./dist/components/Attachment/index.js 109 B
./dist/components/Attachment/UnsupportedAttachment.js 267 B
./dist/components/Attachment/utils.js 1.65 kB
./dist/components/AutoCompleteTextarea/Header.js 332 B
./dist/components/AutoCompleteTextarea/index.js 157 B
./dist/components/AutoCompleteTextarea/Item.js 527 B
./dist/components/AutoCompleteTextarea/List.js 1.52 kB
./dist/components/AutoCompleteTextarea/Textarea.js 6.81 kB
./dist/components/AutoCompleteTextarea/types.js 31 B
./dist/components/AutoCompleteTextarea/utils.js 834 B
./dist/components/Avatar/Avatar.js 740 B
./dist/components/Avatar/index.js 46 B
./dist/components/Channel/channelState.js 1.04 kB
./dist/components/Channel/hooks/useChannelContainerClasses.js 353 B
./dist/components/Channel/hooks/useCreateChannelStateContext.js 1.56 kB
./dist/components/Channel/hooks/useCreateTypingContext.js 235 B
./dist/components/Channel/hooks/useEditMessageHandler.js 252 B
./dist/components/Channel/hooks/useIsMounted.js 168 B
./dist/components/Channel/hooks/useMentionsHandlers.js 422 B
./dist/components/Channel/index.js 117 B
./dist/components/Channel/LoadingChannel.js 360 B
./dist/components/Channel/utils.js 339 B
./dist/components/ChannelHeader/ChannelHeader.js 901 B
./dist/components/ChannelHeader/icons.js 458 B
./dist/components/ChannelHeader/index.js 53 B
./dist/components/ChannelList/ChannelList.js 3.03 kB
./dist/components/ChannelList/ChannelListMessenger.js 490 B
./dist/components/ChannelList/hooks/index.js 196 B
./dist/components/ChannelList/hooks/useChannelDeletedListener.js 454 B
./dist/components/ChannelList/hooks/useChannelHiddenListener.js 450 B
./dist/components/ChannelList/hooks/useChannelTruncatedListener.js 379 B
./dist/components/ChannelList/hooks/useChannelUpdatedListener.js 614 B
./dist/components/ChannelList/hooks/useChannelVisibleListener.js 616 B
./dist/components/ChannelList/hooks/useConnectionRecoveredListener.js 275 B
./dist/components/ChannelList/hooks/useMessageNewListener.js 599 B
./dist/components/ChannelList/hooks/useMobileNavigation.js 276 B
./dist/components/ChannelList/hooks/useNotificationAddedToChannelListener.js 825 B
./dist/components/ChannelList/hooks/useNotificationMessageNewListener.js 702 B
./dist/components/ChannelList/hooks/useNotificationRemovedFromChannelListener.js 411 B
./dist/components/ChannelList/hooks/useUserPresenceChangedListener.js 466 B
./dist/components/ChannelList/index.js 78 B
./dist/components/ChannelList/utils.js 314 B
./dist/components/ChannelPreview/ChannelPreview.js 1.06 kB
./dist/components/ChannelPreview/ChannelPreviewMessenger.js 881 B
./dist/components/ChannelPreview/hooks/index.js 97 B
./dist/components/ChannelPreview/hooks/useChannelPreviewInfo.js 471 B
./dist/components/ChannelPreview/hooks/useIsChannelMuted.js 319 B
./dist/components/ChannelPreview/hooks/useMessageDeliveryStatus.js 829 B
./dist/components/ChannelPreview/index.js 81 B
./dist/components/ChannelPreview/utils.js 695 B
./dist/components/ChannelSearch/ChannelSearch.js 1.11 kB
./dist/components/ChannelSearch/hooks/useChannelSearch.js 2.26 kB
./dist/components/ChannelSearch/icons.js 701 B
./dist/components/ChannelSearch/index.js 85 B
./dist/components/ChannelSearch/SearchBar.js 1.33 kB
./dist/components/ChannelSearch/SearchInput.js 335 B
./dist/components/ChannelSearch/SearchResults.js 1.59 kB
./dist/components/ChannelSearch/utils.js 89 B
./dist/components/Chat/Chat.js 933 B
./dist/components/Chat/hooks/useChannelsQueryState.js 212 B
./dist/components/Chat/hooks/useChat.js 1.46 kB
./dist/components/Chat/hooks/useCreateChatContext.js 671 B
./dist/components/Chat/hooks/useCustomStyles.js 649 B
./dist/components/Chat/index.js 71 B
./dist/components/ChatAutoComplete/ChatAutoComplete.js 1.25 kB
./dist/components/ChatAutoComplete/index.js 56 B
./dist/components/ChatDown/ChatDown.js 530 B
./dist/components/ChatDown/icons.js 1.26 kB
./dist/components/ChatDown/index.js 48 B
./dist/components/CommandItem/CommandItem.js 265 B
./dist/components/CommandItem/index.js 51 B
./dist/components/DateSeparator/DateSeparator.js 514 B
./dist/components/DateSeparator/index.js 53 B
./dist/components/Emojis/EmojiPicker.js 1.31 kB
./dist/components/Emojis/index.js 51 B
./dist/components/EmoticonItem/EmoticonItem.js 417 B
./dist/components/EmoticonItem/index.js 52 B
./dist/components/EmptyStateIndicator/EmptyStateIndicator.js 458 B
./dist/components/EmptyStateIndicator/icons.js 323 B
./dist/components/EmptyStateIndicator/index.js 59 B
./dist/components/EventComponent/EventComponent.js 831 B
./dist/components/EventComponent/index.js 52 B
./dist/components/Gallery/BaseImage.js 481 B
./dist/components/Gallery/Gallery.js 1.13 kB
./dist/components/Gallery/Image.js 681 B
./dist/components/Gallery/index.js 70 B
./dist/components/Gallery/ModalGallery.js 627 B
./dist/components/index.js 307 B
./dist/components/InfiniteScrollPaginator/index.js 54 B
./dist/components/Loading/index.js 76 B
./dist/components/Loading/LoadingChannels.js 285 B
./dist/components/Loading/LoadingErrorIndicator.js 366 B
./dist/components/Loading/LoadingIndicator.js 671 B
./dist/components/LoadMore/index.js 68 B
./dist/components/LoadMore/LoadMoreButton.js 570 B
./dist/components/LoadMore/LoadMorePaginator.js 484 B
./dist/components/Message/FixedHeightMessage.js 1.7 kB
./dist/components/Message/hooks/index.js 146 B
./dist/components/Message/hooks/useActionHandler.js 751 B
./dist/components/Message/hooks/useDeleteHandler.js 616 B
./dist/components/Message/hooks/useEditHandler.js 300 B
./dist/components/Message/hooks/useFlagHandler.js 753 B
./dist/components/Message/hooks/useMarkUnreadHandler.js 714 B
./dist/components/Message/hooks/useMentionsHandler.js 387 B
./dist/components/Message/hooks/useMuteHandler.js 941 B
./dist/components/Message/hooks/useOpenThreadHandler.js 266 B
./dist/components/Message/hooks/usePinHandler.js 930 B
./dist/components/Message/hooks/useReactionHandler.js 2.16 kB
./dist/components/Message/hooks/useReactionsFetcher.js 788 B
./dist/components/Message/hooks/useRetryHandler.js 343 B
./dist/components/Message/hooks/useUserHandler.js 223 B
./dist/components/Message/hooks/useUserRole.js 760 B
./dist/components/Message/icons.js 1.63 kB
./dist/components/Message/index.js 162 B
./dist/components/Message/Message.js 2.31 kB
./dist/components/Message/MessageDeleted.js 374 B
./dist/components/Message/MessageErrorText.js 381 B
./dist/components/Message/MessageOptions.js 951 B
./dist/components/Message/MessageRepliesCountButton.js 523 B
./dist/components/Message/MessageSimple.js 2.45 kB
./dist/components/Message/MessageStatus.js 1.23 kB
./dist/components/Message/MessageText.js 999 B
./dist/components/Message/MessageTimestamp.js 546 B
./dist/components/Message/QuotedMessage.js 817 B
./dist/components/Message/renderText/componentRenderers/Anchor.js 327 B
./dist/components/Message/renderText/componentRenderers/Emoji.js 173 B
./dist/components/Message/renderText/componentRenderers/index.js 65 B
./dist/components/Message/renderText/componentRenderers/Mention.js 195 B
./dist/components/Message/renderText/index.js 132 B
./dist/components/Message/renderText/regex.js 374 B
./dist/components/Message/renderText/rehypePlugins/emojiMarkdownPlugin.js 252 B
./dist/components/Message/renderText/rehypePlugins/index.js 72 B
./dist/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.js 1.04 kB
./dist/components/Message/renderText/remarkPlugins/htmlToTextPlugin.js 178 B
./dist/components/Message/renderText/remarkPlugins/index.js 75 B
./dist/components/Message/renderText/remarkPlugins/keepLineBreaksPlugin.js 531 B
./dist/components/Message/renderText/renderText.js 1.76 kB
./dist/components/Message/renderText/types.js 31 B
./dist/components/Message/types.js 31 B
./dist/components/Message/utils.js 2.92 kB
./dist/components/MessageActions/CustomMessageActionsList.js 346 B
./dist/components/MessageActions/hooks/index.js 66 B
./dist/components/MessageActions/hooks/useMessageActionsBoxPopper.js 517 B
./dist/components/MessageActions/index.js 76 B
./dist/components/MessageActions/MessageActions.js 1.53 kB
./dist/components/MessageActions/MessageActionsBox.js 1.18 kB
./dist/components/MessageBounce/index.js 68 B
./dist/components/MessageBounce/MessageBounceModal.js 253 B
./dist/components/MessageBounce/MessageBouncePrompt.js 507 B
./dist/components/MessageInput/AttachmentPreviewList.js 1.25 kB
./dist/components/MessageInput/CooldownTimer.js 377 B
./dist/components/MessageInput/DefaultTriggerProvider.js 442 B
./dist/components/MessageInput/DropzoneProvider.js 548 B
./dist/components/MessageInput/EditMessageForm.js 1.05 kB
./dist/components/MessageInput/hooks/index.js 78 B
./dist/components/MessageInput/hooks/useAttachments.js 1.02 kB
./dist/components/MessageInput/hooks/useCommandTrigger.js 903 B
./dist/components/MessageInput/hooks/useCooldownTimer.js 818 B
./dist/components/MessageInput/hooks/useCreateMessageInputContext.js 1.42 kB
./dist/components/MessageInput/hooks/useEmojiTrigger.js 734 B
./dist/components/MessageInput/hooks/useFileState.js 169 B
./dist/components/MessageInput/hooks/useFileUploads.js 1.27 kB
./dist/components/MessageInput/hooks/useImageUploads.js 1.38 kB
./dist/components/MessageInput/hooks/useLinkPreviews.js 1.41 kB
./dist/components/MessageInput/hooks/useMessageInputState.js 2.74 kB
./dist/components/MessageInput/hooks/useMessageInputText.js 958 B
./dist/components/MessageInput/hooks/usePasteHandler.js 871 B
./dist/components/MessageInput/hooks/useSubmitHandler.js 2.54 kB
./dist/components/MessageInput/hooks/useUserTrigger.js 1.92 kB
./dist/components/MessageInput/hooks/utils.js 1.69 kB
./dist/components/MessageInput/icons.js 2.85 kB
./dist/components/MessageInput/index.js 181 B
./dist/components/MessageInput/LinkPreviewList.js 778 B
./dist/components/MessageInput/MessageInput.js 641 B
./dist/components/MessageInput/MessageInputFlat.js 2.4 kB
./dist/components/MessageInput/MessageInputSmall.js 1.72 kB
./dist/components/MessageInput/QuotedMessagePreview.js 920 B
./dist/components/MessageInput/types.js 387 B
./dist/components/MessageInput/UploadsPreview.js 871 B
./dist/components/MessageList/ConnectionStatus.js 457 B
./dist/components/MessageList/CustomNotification.js 300 B
./dist/components/MessageList/GiphyPreviewMessage.js 197 B
./dist/components/MessageList/hooks/index.js 183 B
./dist/components/MessageList/hooks/MessageList/index.js 126 B
./dist/components/MessageList/hooks/MessageList/useEnrichedMessages.js 687 B
./dist/components/MessageList/hooks/MessageList/useMessageListElements.js 645 B
./dist/components/MessageList/hooks/MessageList/useMessageListScrollManager.js 960 B
./dist/components/MessageList/hooks/MessageList/useScrollLocationLogic.js 895 B
./dist/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.js 1.03 kB
./dist/components/MessageList/hooks/useLastReadData.js 266 B
./dist/components/MessageList/hooks/useMarkRead.js 1.26 kB
./dist/components/MessageList/hooks/VirtualizedMessageList/index.js 158 B
./dist/components/MessageList/hooks/VirtualizedMessageList/useGiphyPreview.js 423 B
./dist/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.js 388 B
./dist/components/MessageList/hooks/VirtualizedMessageList/useNewMessageNotification.js 691 B
./dist/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.js 1.32 kB
./dist/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.js 471 B
./dist/components/MessageList/hooks/VirtualizedMessageList/useShouldForceScrollToBottom.js 423 B
./dist/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.js 665 B
./dist/components/MessageList/icons.js 622 B
./dist/components/MessageList/index.js 204 B
./dist/components/MessageList/MessageListMainPanel.js 290 B
./dist/components/MessageList/MessageListNotifications.js 471 B
./dist/components/MessageList/MessageNotification.js 293 B
./dist/components/MessageList/renderMessages.js 926 B
./dist/components/MessageList/ScrollToBottomButton.js 1.12 kB
./dist/components/MessageList/UnreadMessagesNotification.js 441 B
./dist/components/MessageList/UnreadMessagesSeparator.js 316 B
./dist/components/MessageList/utils.js 2.79 kB
./dist/components/MessageList/VirtualizedMessageListComponents.js 2 kB
./dist/components/MML/index.js 43 B
./dist/components/MML/MML.js 535 B
./dist/components/Modal/icons.js 435 B
./dist/components/Modal/index.js 45 B
./dist/components/Modal/Modal.js 821 B
./dist/components/ReactFileUtilities/FileIcon/FileIcon.js 536 B
./dist/components/ReactFileUtilities/FileIcon/FileIconSet/v1.js 2.73 kB
./dist/components/ReactFileUtilities/FileIcon/FileIconSet/v2.js 5.46 kB
./dist/components/ReactFileUtilities/FileIcon/iconMap.js 800 B
./dist/components/ReactFileUtilities/FileIcon/index.js 53 B
./dist/components/ReactFileUtilities/FileIcon/mimeTypes.js 834 B
./dist/components/ReactFileUtilities/FilePreviewer.js 634 B
./dist/components/ReactFileUtilities/FileUploadButton.js 543 B
./dist/components/ReactFileUtilities/IconButton.js 320 B
./dist/components/ReactFileUtilities/icons/AttachmentIcon.js 397 B
./dist/components/ReactFileUtilities/icons/CloseIcon.js 560 B
./dist/components/ReactFileUtilities/icons/FilePlaceholderIcon.js 1.52 kB
./dist/components/ReactFileUtilities/icons/index.js 96 B
./dist/components/ReactFileUtilities/icons/PictureIcon.js 333 B
./dist/components/ReactFileUtilities/icons/RetryIcon.js 325 B
./dist/components/ReactFileUtilities/ImageDropzone.js 1.02 kB
./dist/components/ReactFileUtilities/ImagePreviewer.js 779 B
./dist/components/ReactFileUtilities/ImageUploadButton.js 472 B
./dist/components/ReactFileUtilities/index.js 177 B
./dist/components/ReactFileUtilities/LoadingIndicator.js 307 B
./dist/components/ReactFileUtilities/Thumbnail.js 468 B
./dist/components/ReactFileUtilities/ThumbnailPlaceholder.js 384 B
./dist/components/ReactFileUtilities/types.js 31 B
./dist/components/ReactFileUtilities/UploadButton.js 289 B
./dist/components/ReactFileUtilities/utils.js 1.21 kB
./dist/components/Reactions/hooks/useFetchReactions.js 600 B
./dist/components/Reactions/hooks/useProcessReactions.js 1.01 kB
./dist/components/Reactions/index.js 108 B
./dist/components/Reactions/reactionOptions.js 330 B
./dist/components/Reactions/ReactionSelector.js 1.81 kB
./dist/components/Reactions/ReactionsList.js 1.02 kB
./dist/components/Reactions/ReactionsListModal.js 1.23 kB
./dist/components/Reactions/SimpleReactionsList.js 1.05 kB
./dist/components/Reactions/SpriteImage.js 705 B
./dist/components/Reactions/StreamEmoji.js 385 B
./dist/components/Reactions/types.js 31 B
./dist/components/Reactions/utils/utils.js 300 B
./dist/components/SafeAnchor/index.js 74 B
./dist/components/SafeAnchor/SafeAnchor.js 347 B
./dist/components/Thread/icons.js 370 B
./dist/components/Thread/index.js 71 B
./dist/components/Thread/Thread.js 1.52 kB
./dist/components/Thread/ThreadHead.js 314 B
./dist/components/Thread/ThreadHeader.js 464 B
./dist/components/Thread/ThreadStart.js 283 B
./dist/components/Tooltip/hooks/index.js 61 B
./dist/components/Tooltip/hooks/useEnterLeaveHandlers.js 305 B
./dist/components/Tooltip/index.js 47 B
./dist/components/Tooltip/Tooltip.js 478 B
./dist/components/TypingIndicator/index.js 55 B
./dist/components/TypingIndicator/TypingIndicator.js 1.22 kB
./dist/components/UserItem/index.js 48 B
./dist/components/UserItem/UserItem.js 628 B
./dist/components/Window/index.js 46 B
./dist/components/Window/Window.js 372 B
./dist/constants/limits.js 96 B
./dist/constants/messageTypes.js 99 B
./dist/context/ChannelActionContext.js 588 B
./dist/context/ChannelListContext.js 377 B
./dist/context/ChannelStateContext.js 586 B
./dist/context/ChatContext.js 573 B
./dist/context/ComponentContext.js 579 B
./dist/context/index.js 131 B
./dist/context/MessageBounceContext.js 630 B
./dist/context/MessageContext.js 580 B
./dist/context/MessageInputContext.js 350 B
./dist/context/MessageListContext.js 377 B
./dist/context/TranslationContext.js 783 B
./dist/context/TypingContext.js 581 B
./dist/context/utils/getDisplayName.js 102 B
./dist/css/index.css 26.7 kB
./dist/css/v2/emoji-mart.css 1.84 kB
./dist/css/v2/emoji-replacement.css 299 B
./dist/css/v2/index.css 19.8 kB
./dist/css/v2/index.layout.css 8.32 kB
./dist/i18n/de.json 2.4 kB
./dist/i18n/en.json 1.52 kB
./dist/i18n/es.json 2.43 kB
./dist/i18n/fr.json 2.47 kB
./dist/i18n/hi.json 2.77 kB
./dist/i18n/index.js 67 B
./dist/i18n/it.json 2.44 kB
./dist/i18n/ja.json 2.64 kB
./dist/i18n/ko.json 2.56 kB
./dist/i18n/nl.json 2.33 kB
./dist/i18n/pt.json 2.44 kB
./dist/i18n/ru.json 2.93 kB
./dist/i18n/Streami18n.js 5.76 kB
./dist/i18n/tr.json 2.41 kB
./dist/i18n/translations.js 172 B
./dist/i18n/utils.js 528 B
./dist/index_UMD.js 175 B
./dist/index.js 78 B
./dist/types/index.js 31 B
./dist/types/types.js 31 B
./dist/utils/browsers.js 156 B
./dist/utils/deprecationWarning.js 317 B
./dist/utils/generateRandomId.js 130 B
./dist/utils/getChannel.js 968 B
./dist/utils/getWholeChar.js 411 B
./dist/utils/index.js 79 B
./dist/version.js 60 B

compressed-size-action

scrollElement.addEventListener('scroll', scrollListener, useCapture);
scrollElement.addEventListener('resize', scrollListener, useCapture);
scrollListener();
Copy link
Contributor Author

@myandrienko myandrienko Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we'll only load a single additional page of messages in case the first page is not enough to cause overflow of the message list.

To keep loading pages until there is overflow, or there is no more pages to load, we can do something like this:

  useLayoutEffect(() => {
    if (!isLoading) {
      scrollListenerRef.current?.();
    }
  }, [isLoading]);

However, I don't see a way to have the same behavior in the VirtualizedMessageList, and since our default page size is rather big (100 messages), I think it's better to keep things consistent.

@myandrienko myandrienko marked this pull request as ready for review February 22, 2024 17:03
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 85.04%. Comparing base (652e3a5) to head (ff1368a).

Files Patch % Lines
.../components/MessageList/VirtualizedMessageList.tsx 50.00% 1 Missing and 1 partial ⚠️
...mponents/ChannelList/hooks/usePaginatedChannels.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2292      +/-   ##
==========================================
+ Coverage   85.03%   85.04%   +0.01%     
==========================================
  Files         344      344              
  Lines        7689     7702      +13     
  Branches     2140     2143       +3     
==========================================
+ Hits         6538     6550      +12     
+ Misses        807      806       -1     
- Partials      344      346       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arnautov-anton
Copy link
Contributor

Thank you, @myandrienko, closing #2275.

@myandrienko myandrienko merged commit 3685030 into master Feb 23, 2024
8 of 9 checks passed
@myandrienko myandrienko deleted the fix/message-list-has-more branch February 23, 2024 15:20
github-actions bot pushed a commit that referenced this pull request Feb 23, 2024
## [11.10.0](v11.9.0...v11.10.0) (2024-02-23)

### Bug Fixes

* initial message load issues ([#2292](#2292)) ([3685030](3685030))

### Features

* add customizable reaction details sorting ([#2290](#2290)) ([652e3a5](652e3a5)), closes [#2289](#2289)
* add customizable reactions sorting ([#2289](#2289)) ([78c6107](78c6107))
@stream-ci-bot
Copy link

🎉 This PR is included in version 11.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants