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 | */ |
simon | 9f814a3 | 2022-11-22 21:40:53 -0500 | [diff] [blame] | 18 | import { Box, Stack } from '@mui/material'; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 19 | import { ReactNode, useContext } from 'react'; |
Adrien Béraud | 35e7d7c | 2021-04-13 03:28:39 -0400 | [diff] [blame] | 20 | |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 21 | //import Sound from 'react-sound'; |
Adrien Béraud | 995e802 | 2021-04-08 13:46:51 -0400 | [diff] [blame] | 22 | import ConversationList from '../components/ConversationList'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 23 | import Header from '../components/Header'; |
simon | 6b9ddfb | 2022-10-03 00:04:50 -0400 | [diff] [blame] | 24 | import LoadingPage from '../components/Loading'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 25 | import NewContactForm from '../components/NewContactForm'; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 26 | import { MessengerContext } from '../contexts/MessengerProvider'; |
simon | fe1de72 | 2022-10-02 00:21:43 -0400 | [diff] [blame] | 27 | import AddContactPage from './AddContactPage'; |
ervinanoh | 34eb947 | 2022-09-13 04:20:28 -0400 | [diff] [blame] | 28 | |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 29 | const Messenger = ({ children }: { children?: ReactNode }) => { |
| 30 | const { newContactId, conversations } = useContext(MessengerContext); |
Adrien Béraud | 35e7d7c | 2021-04-13 03:28:39 -0400 | [diff] [blame] | 31 | |
Adrien Béraud | 4e287b9 | 2021-04-24 16:15:56 -0400 | [diff] [blame] | 32 | return ( |
simon | 9f814a3 | 2022-11-22 21:40:53 -0500 | [diff] [blame] | 33 | <Box display="flex" height="100%"> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 34 | <Stack flexGrow={0} flexShrink={0} overflow="auto"> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 35 | <Header /> |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 36 | <NewContactForm /> |
simon | ff1cb35 | 2022-11-24 15:15:26 -0500 | [diff] [blame] | 37 | {newContactId && <AddContactPage contactId={newContactId} />} |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 38 | {conversations ? ( |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 39 | <ConversationList conversations={conversations} /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | ) : ( |
| 41 | <div className="rooms-list"> |
| 42 | <LoadingPage /> |
| 43 | </div> |
| 44 | )} |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 45 | </Stack> |
simon | 9f814a3 | 2022-11-22 21:40:53 -0500 | [diff] [blame] | 46 | <Box flexGrow={1} display="flex" position="relative"> |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame^] | 47 | {children} |
simon | 9f814a3 | 2022-11-22 21:40:53 -0500 | [diff] [blame] | 48 | </Box> |
| 49 | </Box> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 50 | ); |
| 51 | }; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 52 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 53 | export default Messenger; |