simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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éraud | ab519ff | 2022-05-03 15:34:48 -0400 | [diff] [blame] | 18 | import { GroupRounded as GroupIcon } from '@mui/icons-material'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 19 | import List from '@mui/material/List'; |
| 20 | import ListSubheader from '@mui/material/ListSubheader'; |
Adrien Béraud | ab519ff | 2022-05-03 15:34:48 -0400 | [diff] [blame] | 21 | import Typography from '@mui/material/Typography'; |
simon | 2007698 | 2022-10-11 15:04:13 -0400 | [diff] [blame] | 22 | import { Conversation } from 'jami-web-common'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 23 | import { useEffect } from 'react'; |
| 24 | |
simon | d8ca2f2 | 2022-10-11 23:30:55 -0400 | [diff] [blame] | 25 | import { useAppSelector } from '../redux/hooks'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 26 | import ConversationListItem from './ConversationListItem'; |
Adrien Béraud | 995e802 | 2021-04-08 13:46:51 -0400 | [diff] [blame] | 27 | |
simon | 6b9ddfb | 2022-10-03 00:04:50 -0400 | [diff] [blame] | 28 | type ConversationListProps = { |
| 29 | accountId: string; |
| 30 | conversations: Conversation[]; |
| 31 | search?: Conversation; |
| 32 | }; |
| 33 | export default function ConversationList(props: ConversationListProps) { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 34 | const { refresh } = useAppSelector((state) => state.app); |
ervinanoh | 34eb947 | 2022-09-13 04:20:28 -0400 | [diff] [blame] | 35 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 36 | useEffect(() => { |
| 37 | console.log('refresh list'); |
| 38 | }, [refresh]); |
ervinanoh | 34eb947 | 2022-09-13 04:20:28 -0400 | [diff] [blame] | 39 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | 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éraud | 995e802 | 2021-04-08 13:46:51 -0400 | [diff] [blame] | 64 | } |