Skip to content

Commit dac9d7e

Browse files
authored
Merge pull request #1932 from GetStream/develop
v10.6.0
2 parents 01cd89f + 34b8e71 commit dac9d7e

File tree

13 files changed

+75
-22
lines changed

13 files changed

+75
-22
lines changed

docusaurus/docs/React/components/contexts/channel-action-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ The function to execute when @mention is hovered in a `message`, takes a DOM cli
146146

147147
### openThread
148148

149-
The function to execute when replies count button is clicked, takes the parent message of the `Thread` to be opened and a DOM click event.
149+
The function to execute when replies count button is clicked, takes the parent message of the `Thread` to be opened and optionally a DOM click event.
150150

151151
| Type |
152152
|----------|

docusaurus/docs/React/guides/customization/thread-header.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const CustomThreadHeader = ({ closeThread, thread }) => {
2727
))}
2828
<div className='reply-count'>{replyCount} Replies</div>
2929
</div>
30-
<div onClick={(event) => closeThread(event)} className='close-button'>
30+
<div onClick={closeThread} className='close-button'>
3131
<div className='left'>
3232
<div className='right'></div>
3333
</div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"react-image-gallery": "^1.2.7",
5252
"react-is": "^18.1.0",
5353
"react-markdown": "^8.0.3",
54-
"react-player": "^2.10.1",
54+
"react-player": "2.10.1",
5555
"react-popper": "^2.3.0",
5656
"react-textarea-autosize": "^8.3.0",
5757
"react-virtuoso": "^2.16.5",

src/components/Channel/Channel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,9 @@ const ChannelInner = <
748748

749749
const openThread = (
750750
message: StreamMessage<StreamChatGenerics>,
751-
event: React.BaseSyntheticEvent,
751+
event?: React.BaseSyntheticEvent,
752752
) => {
753-
event.preventDefault();
753+
event?.preventDefault();
754754
setQuotedMessage((current) => {
755755
if (current?.parent_id !== message?.parent_id) {
756756
return undefined;
@@ -761,8 +761,8 @@ const ChannelInner = <
761761
dispatch({ channel, message, type: 'openThread' });
762762
};
763763

764-
const closeThread = (event: React.BaseSyntheticEvent) => {
765-
event.preventDefault();
764+
const closeThread = (event?: React.BaseSyntheticEvent) => {
765+
event?.preventDefault();
766766
dispatch({ type: 'closeThread' });
767767
};
768768

src/components/MessageList/ConnectionStatus.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ const UnMemoizedConnectionStatus = <
2626
}, [client, online]);
2727

2828
return (
29-
<CustomNotification active={!online} type='error'>
29+
<CustomNotification
30+
active={!online}
31+
className='str-chat__connection-status-notification'
32+
type='error'
33+
>
3034
{t<string>('Connection failure, reconnecting now...')}
3135
</CustomNotification>
3236
);

src/components/MessageList/CustomNotification.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import React, { PropsWithChildren } from 'react';
2+
import clsx from 'clsx';
23

34
export type CustomNotificationProps = {
45
type: string;
56
active?: boolean;
7+
className?: string;
68
};
79

810
const UnMemoizedCustomNotification = (props: PropsWithChildren<CustomNotificationProps>) => {
9-
const { active, children, type } = props;
11+
const { active, children, className, type } = props;
1012

1113
if (!active) return null;
1214

1315
return (
1416
<div
1517
aria-live='polite'
16-
className={`str-chat__custom-notification notification-${type} str-chat__notification`}
18+
className={clsx(
19+
`str-chat__custom-notification notification-${type}`,
20+
`str-chat__notification`,
21+
className,
22+
)}
1723
data-testid='custom-notification'
1824
>
1925
{children}

src/components/MessageList/__tests__/CustomNotification.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,16 @@ describe('CustomNotification', () => {
4242

4343
expect(getByTestId('custom-notification').className).toContain(`notification-${type}`);
4444
});
45+
46+
it('should add custom class to className', () => {
47+
const className = 'custom-classname-xxx';
48+
49+
const { getByTestId } = render(
50+
<CustomNotification active={true} className={className}>
51+
x
52+
</CustomNotification>,
53+
);
54+
55+
expect(getByTestId('custom-notification').className).toContain(className);
56+
});
4557
});

src/components/Thread/Thread.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type ThreadProps<
3838
/** Additional props for `MessageList` component: [available props](https://getstream.io/chat/docs/sdk/react/core-components/message_list/#props) */
3939
additionalMessageListProps?: MessageListProps<StreamChatGenerics>;
4040
/** Additional props for `Message` component of the parent message: [available props](https://getstream.io/chat/docs/sdk/react/message-components/message/#props) */
41-
additionalParentMessageProps?: MessageProps<StreamChatGenerics>;
41+
additionalParentMessageProps?: Partial<MessageProps<StreamChatGenerics>>;
4242
/** Additional props for `VirtualizedMessageList` component: [available props](https://getstream.io/chat/docs/sdk/react/core-components/virtualized_list/#props) */
4343
additionalVirtualizedMessageListProps?: VirtualizedMessageListProps<StreamChatGenerics>;
4444
/** If true, focuses the `MessageInput` component on opening a thread */

src/components/Thread/ThreadHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type ThreadHeaderProps<
1515
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
1616
> = {
1717
/** Callback for closing the thread */
18-
closeThread: (event: React.BaseSyntheticEvent) => void;
18+
closeThread: (event?: React.BaseSyntheticEvent) => void;
1919
/** The thread parent message */
2020
thread: StreamMessage<StreamChatGenerics>;
2121
};
@@ -46,7 +46,7 @@ export const ThreadHeader = <
4646
aria-label='Close thread'
4747
className='str-chat__square-button str-chat__close-thread-button'
4848
data-testid='close-button'
49-
onClick={(event) => closeThread(event)}
49+
onClick={closeThread}
5050
>
5151
<CloseIcon />
5252
</button>

src/components/Window/Window.tsx

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

34
import { StreamMessage, useChannelStateContext } from '../../context/ChannelStateContext';
45

@@ -9,7 +10,7 @@ export type WindowProps<
910
> = {
1011
/** show or hide the window when a thread is active */
1112
hideOnThread?: boolean;
12-
/** optional prop to manually trigger the opening of a thread*/
13+
/** optional prop to force addition of class str-chat__main-panel--hideOnThread to the Window root element */
1314
thread?: StreamMessage<StreamChatGenerics>;
1415
};
1516

@@ -18,15 +19,15 @@ const UnMemoizedWindow = <
1819
>(
1920
props: PropsWithChildren<WindowProps<StreamChatGenerics>>,
2021
) => {
21-
const { children, hideOnThread = false } = props;
22+
const { children, hideOnThread = false, thread: propThread } = props;
2223

23-
const { thread } = useChannelStateContext<StreamChatGenerics>('Window');
24+
const { thread: contextThread } = useChannelStateContext<StreamChatGenerics>('Window');
2425

2526
return (
2627
<div
27-
className={`str-chat__main-panel ${
28-
hideOnThread && thread ? 'str-chat__main-panel--hideOnThread' : ''
29-
}`}
28+
className={clsx('str-chat__main-panel', {
29+
'str-chat__main-panel--hideOnThread': hideOnThread && (contextThread || propThread),
30+
})}
3031
>
3132
{children}
3233
</div>

0 commit comments

Comments
 (0)