* Feature 🚀 : Ability to delete messages in chat channels - Sending message ID to frontend - Deleting Message - Use pusher to delete message realtime * Minor Bug 🐞: Show message action only for current user - User can delete or edit their own messages * Test cases added * Bug 🐞: Update message id for receiver Message id was not sent to receiver by pusher * Refactoring🛠: Message controller refactoring * Test Cases📝 : Specs for Delete message added * Feature 🚀 : Ability to edit messages * Test Cases📝 : Specs for Edit message added * Feature 🚀 : Ability to mention member in Group [Frontend] * Test Cases📝 : Test Cases added * Feature 🚀 : Ability to mention member in Group [Backend] * Bug Fix 🐞: Making messages realtime for open channels * Feature 🚀 and Bug Fix 🐞: Ability to get notification if mentioned in open messages and increasing message number count * Feature 🚀 : Ability to remove message count on channel open * Bug Fix 🐞: Making Notification more reliable by checking if the new message is notified to user or not * Feature 🚀 : Ability to metion @all and notify them * Bug Fix 🐞: Minor fixes * Fews tweaks in code * Bug Fix 🐞: Feature was not present for Invite only Section * Bug Fix 🐞: In open channels one can't mention all * Bug Fix 🐞: Markdown conversion for all only in case of invite only * Specs added * Delete schema.rb * Schema file updated * Code refactoring * Further Code refactoring backend * Further Code refactoring backend * Bug Fix 🐞: Mention List error problem in switching tabs * Test Snapshots added * Feature 🚀 : Ability to mention member in Group [Frontend] * Test Cases📝 : Test Cases added * Feature 🚀 : Ability to mention member in Group [Backend] * Bug Fix 🐞: Making messages realtime for open channels * Feature 🚀 and Bug Fix 🐞: Ability to get notification if mentioned in open messages and increasing message number count * Feature 🚀 : Ability to remove message count on channel open * Bug Fix 🐞: Making Notification more reliable by checking if the new message is notified to user or not * Feature 🚀 : Ability to metion @all and notify them * Bug Fix 🐞: Minor fixes * Fews tweaks in code * Bug Fix 🐞: Feature was not present for Invite only Section * Bug Fix 🐞: In open channels one can't mention all * Bug Fix 🐞: Markdown conversion for all only in case of invite only * Specs added * Code refactoring * Further Code refactoring backend * Further Code refactoring backend * Bug Fix 🐞: Mention List error problem in switching tabs * Test Snapshots added * Feature 🚀: Ability to navigate through user list with keyboard only * Bug Fix 🐞: Changing color of group avatars in dark themes * Bug Fix 🐞: Setup pusher channel for open channels also
128 lines
3.8 KiB
JavaScript
128 lines
3.8 KiB
JavaScript
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,
|
|
incomingVideoCallChannelIds,
|
|
}) => {
|
|
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';
|
|
if (incomingVideoCallChannelIds.indexOf(channel.chat_channel_id) > -1) {
|
|
newMessagesIndicator = 'video';
|
|
}
|
|
const otherClassname = isActive
|
|
? 'chatchanneltab--active'
|
|
: 'chatchanneltab--inactive';
|
|
return (
|
|
<button
|
|
type="button"
|
|
key={channel.id}
|
|
className="chatchanneltabbutton"
|
|
onClick={handleSwitchChannel}
|
|
data-channel-id={channel.chat_channel_id}
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
>
|
|
<span
|
|
className={`chatchanneltab ${otherClassname} chatchanneltab--${newMessagesIndicator}`}
|
|
data-channel-id={channel.chat_channel_id}
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
style={{
|
|
border: `1px solid ${channel.channel_color}`,
|
|
boxShadow: `3px 3px 0px ${channel.channel_color}`,
|
|
}}
|
|
>
|
|
<span
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
className={`chatchanneltabindicator chatchanneltabindicator--${newMessagesIndicator}`}
|
|
data-channel-id={channel.chat_channel_id}
|
|
>
|
|
<img
|
|
src={channel.channel_image}
|
|
alt="pic"
|
|
className={
|
|
channel.channel_type === 'direct'
|
|
? 'chatchanneltabindicatordirectimage'
|
|
: 'chatchanneltabindicatordirectimage invert-channel-image'
|
|
}
|
|
/>
|
|
</span>
|
|
{channel.channel_name}
|
|
</span>
|
|
</button>
|
|
);
|
|
});
|
|
let topNotice = '';
|
|
if (
|
|
expanded &&
|
|
filterQuery.length === 0 &&
|
|
channelsLoaded &&
|
|
(channels.length === 0 || channels[0].messages_count === 0)
|
|
) {
|
|
topNotice = (
|
|
<div className="chatchannels__channelslistheader">
|
|
<span role="img" aria-label="emoji">
|
|
👋
|
|
</span>
|
|
{' '}
|
|
Welcome to
|
|
<b> DEV Connect</b>
|
|
! You may message anyone you mutually follow.
|
|
</div>
|
|
);
|
|
}
|
|
let channelsListFooter = '';
|
|
if (channels.length === 30) {
|
|
channelsListFooter = (
|
|
<div className="chatchannels__channelslistfooter">...</div>
|
|
);
|
|
}
|
|
let configFooter = '';
|
|
if (expanded) {
|
|
configFooter = (
|
|
<div className="chatchannels__config">
|
|
<img alt="" src={ConfigImage} style={{ height: '18px' }} />
|
|
<div className="chatchannels__configmenu">
|
|
<a href="/settings">DEV Settings</a>
|
|
<a href="/report-abuse">Report Abuse</a>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
return (
|
|
<div className="chatchannels">
|
|
<div
|
|
className="chatchannels__channelslist"
|
|
id="chatchannels__channelslist"
|
|
>
|
|
{topNotice}
|
|
{channels}
|
|
{channelsListFooter}
|
|
</div>
|
|
{configFooter}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
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,
|
|
incomingVideoCallChannelIds: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
};
|
|
|
|
export default Channels;
|