import { h } from 'preact'; import PropTypes from 'prop-types'; // eslint-disable-next-line import/no-unresolved import ConfigImage from 'images/three-dots.svg'; const Channels = ({ activeChannelId, chatChannels, unopenedChannelIds, handleSwitchChannel, expanded, filterQuery, channelsLoaded, }) => { const channels = chatChannels.map(channel => { const isActive = parseInt(activeChannelId, 10) === channel.chat_channel_id; const isUnopened = !isActive && unopenedChannelIds.includes(channel.chat_channel_id); let newMessagesIndicator = isUnopened ? 'new' : 'old'; const otherClassname = isActive ? 'chatchanneltab--active' : 'chatchanneltab--inactive'; return ( ); }); let topNotice = ''; if ( expanded && filterQuery.length === 0 && channelsLoaded && (channels.length === 0 || channels[0].messages_count === 0) ) { topNotice = (
👋 {' '} Welcome to DEV Connect ! You may message anyone you mutually follow.
); } let channelsListFooter = ''; if (channels.length === 30) { channelsListFooter = (
...
); } let configFooter = ''; if (expanded) { configFooter = (
DEV Settings Report Abuse
); } return (
{topNotice} {channels} {channelsListFooter}
{configFooter}
); }; Channels.propTypes = { activeChannelId: PropTypes.number.isRequired, chatChannels: PropTypes.arrayOf(PropTypes.objectOf()).isRequired, unopenedChannelIds: PropTypes.arrayOf().isRequired, handleSwitchChannel: PropTypes.func.isRequired, expanded: PropTypes.bool.isRequired, filterQuery: PropTypes.string.isRequired, channelsLoaded: PropTypes.bool.isRequired, }; export default Channels;