blob: 316792b7f5e82fa2ce3db958a06d0a6db57c6523 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
Adrien Béraudab519ff2022-05-03 15:34:48 -040018import { GroupRounded as GroupIcon } from '@mui/icons-material';
simon07b4eb02022-09-29 17:50:26 -040019import List from '@mui/material/List';
20import ListSubheader from '@mui/material/ListSubheader';
Adrien Béraudab519ff2022-05-03 15:34:48 -040021import Typography from '@mui/material/Typography';
simon20076982022-10-11 15:04:13 -040022import { Conversation } from 'jami-web-common';
simon07b4eb02022-09-29 17:50:26 -040023import { useEffect } from 'react';
24
simond8ca2f22022-10-11 23:30:55 -040025import { useAppSelector } from '../redux/hooks';
simon07b4eb02022-09-29 17:50:26 -040026import ConversationListItem from './ConversationListItem';
Adrien Béraud995e8022021-04-08 13:46:51 -040027
simon6b9ddfb2022-10-03 00:04:50 -040028type ConversationListProps = {
29 accountId: string;
30 conversations: Conversation[];
31 search?: Conversation;
32};
33export default function ConversationList(props: ConversationListProps) {
Michelle Sepkap Simee580f422022-10-31 23:27:04 -040034 const { refresh } = useAppSelector((state) => state.userInfo);
ervinanoh34eb9472022-09-13 04:20:28 -040035
simond47ef9e2022-09-28 22:24:28 -040036 useEffect(() => {
37 console.log('refresh list');
38 }, [refresh]);
ervinanoh34eb9472022-09-13 04:20:28 -040039
simond47ef9e2022-09-28 22:24:28 -040040 return (
41 <div className="rooms-list">
42 <List>
43 {props.search instanceof Conversation && (
44 <div>
45 <ListSubheader>Public directory</ListSubheader>
46 <ConversationListItem conversation={props.search} />
47 <ListSubheader>Conversations</ListSubheader>
48 </div>
49 )}
50 {props.conversations.map((conversation) => (
51 <ConversationListItem key={conversation.getId()} conversation={conversation} />
52 ))}
53 {props.conversations.length === 0 && (
54 <div className="list-placeholder">
55 <GroupIcon color="disabled" fontSize="large" />
56 <Typography className="subtitle" variant="subtitle2">
57 No conversation yet
58 </Typography>
59 </div>
60 )}
61 </List>
62 </div>
63 );
Adrien Béraud995e8022021-04-08 13:46:51 -040064}