import { h } from 'preact'; import PropTypes from 'prop-types'; import ConfigImage from 'images/three-dots.svg'; import GroupImage from 'images/organization.svg'; const Channels = ({ activeChannelId, chatChannels, handleSwitchChannel, expanded, filterQuery, channelsLoaded, incomingVideoCallChannelIds, }) => { const channels = chatChannels.map(channel => { const isActive = parseInt(activeChannelId, 10) === channel.chat_channel_id; const lastOpened = channel.last_opened_at; const isUnopened = new Date(channel.channel_last_message_at) > new Date(lastOpened) && channel.channel_messages_count > 0; let newMessagesIndicator = isUnopened ? 'new' : 'old'; if (incomingVideoCallChannelIds.indexOf(channel.chat_channel_id) > -1) { newMessagesIndicator = 'video'; } 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.array.isRequired, handleSwitchChannel: PropTypes.func.isRequired, expanded: PropTypes.bool.isRequired, filterQuery: PropTypes.string.isRequired, channelsLoaded: PropTypes.bool.isRequired, incomingVideoCallChannelIds: PropTypes.array.isRequired, }; export default Channels;