Skip to content

Commit d47b87a

Browse files
committed
fix: prevent rendering placeholder for empty message list if messages are actually loaded
1 parent ef467cd commit d47b87a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/components/Channel/Channel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ const ChannelInner = <
392392
...initialState,
393393
hasMore: channel.state.messagePagination.hasPrev,
394394
loading: !channel.initialized,
395+
messages: channel.state.messages,
395396
},
396397
);
397398
const jumpToMessageFromSearch = useSearchFocusedMessage();

src/components/MessageList/VirtualizedMessageListComponents.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ export const EmptyPlaceholder = <
101101
}: CommonVirtuosoComponentProps<StreamChatGenerics>) => {
102102
const { EmptyStateIndicator = DefaultEmptyStateIndicator } =
103103
useComponentContext<StreamChatGenerics>('VirtualizedMessageList');
104+
105+
// prevent showing that there are no messages if there actually are messages (for some reason virtuoso decides to render empty placeholder first, even though it has the totalCount prop > 0)
106+
if (
107+
typeof context?.processedMessages !== 'undefined' &&
108+
context.processedMessages.length > 0
109+
)
110+
return null;
111+
104112
return (
105113
<>
106114
{EmptyStateIndicator && (

0 commit comments

Comments
 (0)