Skip to content

Commit 9c1a16f

Browse files
authored
fix: display messages in virtualized thread (theme v2) (#1799)
* fix: remove use of displayLeft MessageOptions prop in example apps * feat: add conditionally new class str-chat__thread--virtualized on thread root element * chore(deps): bump @stream-io/stream-chat-css to 3.5.4
1 parent 71da77a commit 9c1a16f

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

examples/capacitor/src/components/CustomMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const CustomMessage = () => {
3131
<div className='message-wrapper'>
3232
<Avatar image={message.user?.image} />
3333
<div className='message-wrapper-content'>
34-
<MessageOptions displayLeft={false} messageWrapperRef={messageWrapperRef} />
34+
<MessageOptions messageWrapperRef={messageWrapperRef} />
3535
<div className='message-header'>
3636
<div className='message-header-name'>{message.user?.name}</div>
3737
<div className='message-header-timestamp'>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@braintree/sanitize-url": "6.0.0",
3232
"@popperjs/core": "^2.11.5",
33-
"@stream-io/stream-chat-css": "^3.5.3",
33+
"@stream-io/stream-chat-css": "^3.5.4",
3434
"clsx": "^1.1.1",
3535
"dayjs": "^1.10.4",
3636
"emoji-mart": "3.0.1",

src/components/Thread/Thread.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect } from 'react';
2+
import clsx from 'clsx';
23

34
import { MESSAGE_ACTIONS } from '../Message';
45
import {
@@ -130,7 +131,13 @@ const ThreadInner = <
130131

131132
if (!thread) return null;
132133

133-
const threadClass = customClasses?.thread || 'str-chat__thread-container str-chat__thread';
134+
const threadClass =
135+
customClasses?.thread ||
136+
clsx('str-chat__thread-container str-chat__thread', {
137+
'str-chat__thread--full': fullWidth,
138+
'str-chat__thread--virtualized': virtualized,
139+
});
140+
134141
const head = (
135142
<ThreadHead
136143
key={thread.id}
@@ -141,7 +148,7 @@ const ThreadInner = <
141148
);
142149

143150
return (
144-
<div className={`${threadClass} ${fullWidth ? 'str-chat__thread--full' : ''}`}>
151+
<div className={threadClass}>
145152
<ThreadHeader closeThread={closeThread} thread={thread} />
146153
<ThreadMessageList
147154
disableDateSeparator={!enableDateSeparator}

src/components/Thread/__tests__/Thread.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jest.mock('../../Message/Message', () => ({
3535
jest.mock('../../MessageList/MessageList', () => ({
3636
MessageList: jest.fn(() => <div />),
3737
}));
38+
jest.mock('../../MessageList/VirtualizedMessageList', () => ({
39+
VirtualizedMessageList: jest.fn(() => <div />),
40+
}));
3841
jest.mock('../../MessageInput/MessageInputSmall', () => ({
3942
MessageInputSmall: jest.fn(() => <div />),
4043
}));
@@ -266,6 +269,22 @@ describe('Thread', () => {
266269
expect(container.querySelector('.str-chat__thread--full')).not.toBeInTheDocument();
267270
});
268271

272+
it('should assign str-chat__thread--virtualized class to the root in virtualized mode', () => {
273+
const { container } = renderComponent({
274+
chatClient,
275+
threadProps: { virtualized: true },
276+
});
277+
expect(container.querySelector('.str-chat__thread--virtualized')).toBeInTheDocument();
278+
});
279+
280+
it('should not assign str-chat__thread--virtualized class to the root in non-virtualized mode', () => {
281+
const { container } = renderComponent({
282+
chatClient,
283+
threadProps: { virtualized: false },
284+
});
285+
expect(container.querySelector('.str-chat__thread--virtualized')).not.toBeInTheDocument();
286+
});
287+
269288
it('should not render anything if the thread in context is falsy', () => {
270289
const { container } = renderComponent({
271290
channelStateOverrides: { thread: null },

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,10 +2078,10 @@
20782078
crypto-browserify "^3.11.0"
20792079
process-es6 "^0.11.2"
20802080

2081-
"@stream-io/stream-chat-css@^3.5.3":
2082-
version "3.5.3"
2083-
resolved "https://registry.yarnpkg.com/@stream-io/stream-chat-css/-/stream-chat-css-3.5.3.tgz#bf9c9a075e270517a876aa7f0c819157c0139de8"
2084-
integrity sha512-oUfYH8YC6hH2/eZTgiyOJ0J9ZnK+4baMgS+K1QGi3gsxjXok+645ffpYFGjEVrHVAFGvcwa7l4HzMWn6dCzliQ==
2081+
"@stream-io/stream-chat-css@^3.5.4":
2082+
version "3.5.4"
2083+
resolved "https://registry.yarnpkg.com/@stream-io/stream-chat-css/-/stream-chat-css-3.5.4.tgz#0a6ed50e0f671c61684d325fb3f10712ea674590"
2084+
integrity sha512-g2MviK1mTWyTm+sLtbltuoabbx6d7orC0bUxuRAR0snJgOXBsjwMjCBbkow/rlo6KlqjfCjBhaHE7Ht9NBKHjw==
20852085

20862086
"@stream-io/transliterate@^1.5.5":
20872087
version "1.5.5"

0 commit comments

Comments
 (0)