Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added no pinned messages and no starred messages text in the message list component. #500

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions packages/react/src/components/MessageList/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {
useSearchMessageStore,
useChannelStore,
useUserStore,
useMentionsStore,
useThreadsMessageStore,
} from '../../store';
import RoomMembers from '../RoomMembers/RoomMember';
import MessageReportWindow from '../ReportMessage/MessageReportWindow';
import isMessageSequential from '../../lib/isMessageSequential';
import SearchMessage from '../SearchMessage/SearchMessage';
import Roominfo from '../RoomInformation/RoomInformation';
import AllThreads from '../AllThreads/AllThreads';
import UserMentions from '../UserMentions/UserMentions';
import { Message } from '../Message';
import { Icon } from '../Icon';

import useThreadsMessageStore from '../../store/threadsMessageStore';
Yashraj7890 marked this conversation as resolved.
Show resolved Hide resolved

const MessageList = ({ messages }) => {
const showSearch = useSearchMessageStore((state) => state.showSearch);
Expand All @@ -27,14 +27,29 @@ const MessageList = ({ messages }) => {
const showReportMessage = useMessageStore((state) => state.showReportMessage);
const messageToReport = useMessageStore((state) => state.messageToReport);
const showAvatar = useUserStore((state) => state.showAvatar);
const headerTitle = useMessageStore((state) => state.headerTitle);
const showAllThreads = useThreadsMessageStore(
(state) => state.showAllThreads
);
const showMentions = useMentionsStore((state) => state.showMentions);

const isMessageNewDay = (current, previous) =>
!previous || !isSameDay(new Date(current.ts), new Date(previous.ts));

let iconType = 'thread';
if (headerTitle === 'Pinned Messages') {
iconType = 'pin';
} else if (headerTitle === 'Starred Messages') {
iconType = 'star';
}
if (messages.length === 0) {
return (
<div style={{ margin: 'auto' }}>
<div style={{ textAlign: 'center' }}>
<Icon name={iconType} size="2rem" />
</div>
<div style={{ textAlign: 'center' }}>No {headerTitle}</div>
</div>
);
}
return (
<>
{messages &&
Expand All @@ -61,7 +76,6 @@ const MessageList = ({ messages }) => {
{showSearch && <SearchMessage />}
{showChannelinfo && <Roominfo />}
{showAllThreads && <AllThreads />}
{showMentions && <UserMentions />}
Yashraj7890 marked this conversation as resolved.
Show resolved Hide resolved
</>
);
};
Expand Down
Loading