blob: 38628ade6a68965cc5536694de2c199663b9ff8c [file] [log] [blame]
simond47ef9e2022-09-28 22:24:28 -04001import List from '@mui/material/List';
2import { useEffect } from 'react';
3import ConversationListItem from './ConversationListItem';
Adrien Béraudab519ff2022-05-03 15:34:48 -04004import ListSubheader from '@mui/material/ListSubheader';
Adrien Béraud35e7d7c2021-04-13 03:28:39 -04005import Conversation from '../../../model/Conversation';
Adrien Béraudab519ff2022-05-03 15:34:48 -04006import { GroupRounded as GroupIcon } from '@mui/icons-material';
7import Typography from '@mui/material/Typography';
ervinanoh34eb9472022-09-13 04:20:28 -04008import { useAppSelector } from '../../redux/hooks';
Adrien Béraud995e8022021-04-08 13:46:51 -04009
Adrien Béraudaf09a462021-04-15 18:02:29 -040010export default function ConversationList(props) {
simond47ef9e2022-09-28 22:24:28 -040011 const { refresh } = useAppSelector((state) => state.app);
ervinanoh34eb9472022-09-13 04:20:28 -040012
simond47ef9e2022-09-28 22:24:28 -040013 useEffect(() => {
14 console.log('refresh list');
15 }, [refresh]);
ervinanoh34eb9472022-09-13 04:20:28 -040016
simond47ef9e2022-09-28 22:24:28 -040017 return (
18 <div className="rooms-list">
19 <List>
20 {props.search instanceof Conversation && (
21 <div>
22 <ListSubheader>Public directory</ListSubheader>
23 <ConversationListItem conversation={props.search} />
24 <ListSubheader>Conversations</ListSubheader>
25 </div>
26 )}
27 {props.conversations.map((conversation) => (
28 <ConversationListItem key={conversation.getId()} conversation={conversation} />
29 ))}
30 {props.conversations.length === 0 && (
31 <div className="list-placeholder">
32 <GroupIcon color="disabled" fontSize="large" />
33 <Typography className="subtitle" variant="subtitle2">
34 No conversation yet
35 </Typography>
36 </div>
37 )}
38 </List>
39 </div>
40 );
Adrien Béraud995e8022021-04-08 13:46:51 -040041}