|
1 | | -// @ts-check |
2 | 1 | import React, { useContext } from 'react'; |
3 | 2 | import PropTypes from 'prop-types'; |
4 | 3 | import { Avatar as DefaultAvatar } from '../Avatar'; |
5 | | -import { ChannelContext, TranslationContext, ChatContext } from '../../context'; |
| 4 | +import { ChannelContext, ChatContext, TranslationContext } from '../../context'; |
6 | 5 |
|
7 | 6 | /** |
8 | 7 | * ChannelHeader - Render some basic information about this channel |
9 | 8 | * @example ../../docs/ChannelHeader.md |
10 | 9 | * @type {React.FC<import('types').ChannelHeaderProps>} |
11 | 10 | */ |
12 | | -const ChannelHeader = ({ Avatar = DefaultAvatar, title, live }) => { |
13 | | - /** @type {import("types").TranslationContextValue} */ |
14 | | - const { t } = useContext(TranslationContext); |
15 | | - /** @type {import("types").ChannelContextValue} */ |
| 11 | +const ChannelHeader = (props) => { |
| 12 | + const { Avatar = DefaultAvatar, image: propImage, live, title } = props; |
| 13 | + |
16 | 14 | const { channel, watcher_count } = useContext(ChannelContext); |
17 | 15 | const { openMobileNav } = useContext(ChatContext); |
18 | | - const { image, member_count, name, subtitle } = channel?.data || {}; |
| 16 | + const { t } = useContext(TranslationContext); |
| 17 | + |
| 18 | + const { image: channelImage, member_count, name, subtitle } = |
| 19 | + channel?.data || {}; |
| 20 | + |
| 21 | + const image = propImage || channelImage; |
19 | 22 |
|
20 | 23 | return ( |
21 | 24 | <div className="str-chat__header-livestream"> |
@@ -68,10 +71,12 @@ ChannelHeader.propTypes = { |
68 | 71 | * Defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.js) |
69 | 72 | * */ |
70 | 73 | Avatar: /** @type {PropTypes.Validator<React.ElementType<import('types').AvatarProps>>} */ (PropTypes.elementType), |
71 | | - /** Set title manually */ |
72 | | - title: PropTypes.string, |
| 74 | + /** Manually set the image to render, defaults to the channel image */ |
| 75 | + image: PropTypes.string, |
73 | 76 | /** Show a little indicator that the channel is live right now */ |
74 | 77 | live: PropTypes.bool, |
| 78 | + /** Set title manually */ |
| 79 | + title: PropTypes.string, |
75 | 80 | }; |
76 | 81 |
|
77 | 82 | export default React.memo(ChannelHeader); |
0 commit comments