blob: 59ccfc387f76438ba0b9d99d4a314ac86bf92791 [file] [log] [blame]
Adrien Béraudab519ff2022-05-03 15:34:48 -04001import { GroupRounded as GroupIcon } from '@mui/icons-material';
simon07b4eb02022-09-29 17:50:26 -04002import List from '@mui/material/List';
3import ListSubheader from '@mui/material/ListSubheader';
Adrien Béraudab519ff2022-05-03 15:34:48 -04004import Typography from '@mui/material/Typography';
simon07b4eb02022-09-29 17:50:26 -04005import { useEffect } from 'react';
6
7import Conversation from '../../../model/Conversation';
ervinanoh34eb9472022-09-13 04:20:28 -04008import { useAppSelector } from '../../redux/hooks';
simon07b4eb02022-09-29 17:50:26 -04009import ConversationListItem from './ConversationListItem';
Adrien Béraud995e8022021-04-08 13:46:51 -040010
simon6b9ddfb2022-10-03 00:04:50 -040011type ConversationListProps = {
12 accountId: string;
13 conversations: Conversation[];
14 search?: Conversation;
15};
16export default function ConversationList(props: ConversationListProps) {
simond47ef9e2022-09-28 22:24:28 -040017 const { refresh } = useAppSelector((state) => state.app);
ervinanoh34eb9472022-09-13 04:20:28 -040018
simond47ef9e2022-09-28 22:24:28 -040019 useEffect(() => {
20 console.log('refresh list');
21 }, [refresh]);
ervinanoh34eb9472022-09-13 04:20:28 -040022
simond47ef9e2022-09-28 22:24:28 -040023 return (
24 <div className="rooms-list">
25 <List>
26 {props.search instanceof Conversation && (
27 <div>
28 <ListSubheader>Public directory</ListSubheader>
29 <ConversationListItem conversation={props.search} />
30 <ListSubheader>Conversations</ListSubheader>
31 </div>
32 )}
33 {props.conversations.map((conversation) => (
34 <ConversationListItem key={conversation.getId()} conversation={conversation} />
35 ))}
36 {props.conversations.length === 0 && (
37 <div className="list-placeholder">
38 <GroupIcon color="disabled" fontSize="large" />
39 <Typography className="subtitle" variant="subtitle2">
40 No conversation yet
41 </Typography>
42 </div>
43 )}
44 </List>
45 </div>
46 );
Adrien Béraud995e8022021-04-08 13:46:51 -040047}