blob: e25dd9c45bb2c53eb15d7e845d61c1c128778afe [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
Adrien Béraudaf09a462021-04-15 18:02:29 -040011export default function ConversationList(props) {
simond47ef9e2022-09-28 22:24:28 -040012 const { refresh } = useAppSelector((state) => state.app);
ervinanoh34eb9472022-09-13 04:20:28 -040013
simond47ef9e2022-09-28 22:24:28 -040014 useEffect(() => {
15 console.log('refresh list');
16 }, [refresh]);
ervinanoh34eb9472022-09-13 04:20:28 -040017
simond47ef9e2022-09-28 22:24:28 -040018 return (
19 <div className="rooms-list">
20 <List>
21 {props.search instanceof Conversation && (
22 <div>
23 <ListSubheader>Public directory</ListSubheader>
24 <ConversationListItem conversation={props.search} />
25 <ListSubheader>Conversations</ListSubheader>
26 </div>
27 )}
28 {props.conversations.map((conversation) => (
29 <ConversationListItem key={conversation.getId()} conversation={conversation} />
30 ))}
31 {props.conversations.length === 0 && (
32 <div className="list-placeholder">
33 <GroupIcon color="disabled" fontSize="large" />
34 <Typography className="subtitle" variant="subtitle2">
35 No conversation yet
36 </Typography>
37 </div>
38 )}
39 </List>
40 </div>
41 );
Adrien Béraud995e8022021-04-08 13:46:51 -040042}