Skip to content

Commit 30746c0

Browse files
committed
refactor: remove ChannelAvatar key from component context
1 parent 634de23 commit 30746c0

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

src/components/ChannelPreview/ChannelPreviewMessenger.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const UnMemoizedChannelPreviewMessenger = <
1515
) => {
1616
const {
1717
active,
18-
Avatar: PropsAvatar = DefaultAvatar,
18+
Avatar = DefaultAvatar,
1919
channel,
2020
className: customClassName = '',
2121
displayImage,
@@ -28,10 +28,8 @@ const UnMemoizedChannelPreviewMessenger = <
2828
watchers,
2929
} = props;
3030

31-
const {
32-
ChannelAvatar,
33-
ChannelPreviewActionButtons = DefaultChannelPreviewActionButtons,
34-
} = useComponentContext<SCG>();
31+
const { ChannelPreviewActionButtons = DefaultChannelPreviewActionButtons } =
32+
useComponentContext<SCG>();
3533

3634
const channelPreviewButton = useRef<HTMLButtonElement | null>(null);
3735

@@ -49,8 +47,6 @@ const UnMemoizedChannelPreviewMessenger = <
4947
}
5048
};
5149

52-
const Avatar = ChannelAvatar ?? PropsAvatar;
53-
5450
return (
5551
<div className='str-chat__channel-preview-container'>
5652
<ChannelPreviewActionButtons channel={channel} />

src/components/ChannelPreview/__tests__/ChannelPreviewMessenger.test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ describe('ChannelPreviewMessenger', () => {
6060
expect(container).toMatchSnapshot();
6161
});
6262

63-
it('gives preference to ChannelAvatar from component context over the props Avatar component', () => {
64-
const channelAvatarTestID = 'custom-channel-avatar';
65-
const propsAvatarTestID = 'props-avatar';
66-
const ChannelAvatar = () => <div data-testid={channelAvatarTestID} />;
67-
const PropsAvatar = () => <div data-testid={propsAvatarTestID} />;
68-
render(
69-
renderComponent(
70-
{
71-
Avatar: PropsAvatar,
72-
},
73-
{ ChannelAvatar },
74-
),
75-
);
76-
expect(screen.queryByTestId(propsAvatarTestID)).not.toBeInTheDocument();
77-
expect(screen.getByTestId(channelAvatarTestID)).toBeInTheDocument();
78-
});
79-
8063
it('should call setActiveChannel on click', async () => {
8164
const setActiveChannel = jest.fn();
8265
const { container, getByTestId } = render(

src/context/ComponentContext.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
AttachmentProps,
66
AvatarProps,
77
BaseImageProps,
8-
ChannelAvatarProps,
98
ChannelPreviewActionButtonsProps,
109
CooldownTimerProps,
1110
CustomMessageActionsListProps,
@@ -91,8 +90,6 @@ export type ComponentContextValue<
9190
Avatar?: React.ComponentType<AvatarProps<StreamChatGenerics>>;
9291
/** Custom UI component to display <img/> elements resp. a fallback in case of load error, defaults to and accepts same props as: [BaseImage](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Gallery/BaseImage.tsx) */
9392
BaseImage?: React.ComponentType<BaseImageProps>;
94-
/** Custom UI component to display channel avatar that may be different from a simple user avatar, defaults to and accepts same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */
95-
ChannelAvatar?: React.ComponentType<ChannelAvatarProps>;
9693
/** Custom UI component to display set of action buttons within `ChannelPreviewMessenger` component, accepts same props as: [ChannelPreviewActionButtons](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelList/ChannelPreviewActionButtons.tsx) */
9794
ChannelPreviewActionButtons?: React.ComponentType<
9895
ChannelPreviewActionButtonsProps<StreamChatGenerics>

0 commit comments

Comments
 (0)