blob: b636ec35404e1663b9de9a43b8adacc50c34fb33 [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 */
idillonae655dd2022-10-14 18:11:02 -040018import { Divider, Stack, Typography } from '@mui/material';
simon07b4eb02022-09-29 17:50:26 -040019
idillon255682e2023-02-06 13:25:26 -050020import { useCallManagerContext } from '../contexts/CallManagerProvider';
simon09fe4822022-11-30 23:36:25 -050021import { useConversationContext } from '../contexts/ConversationProvider';
simone35acc22022-12-02 16:51:12 -050022import CallInterface from '../pages/CallInterface';
idillon6847e252022-11-04 11:50:08 -040023import ChatInterface from '../pages/ChatInterface';
idillonae655dd2022-10-14 18:11:02 -040024import { AddParticipantButton, ShowOptionsMenuButton, StartAudioCallButton, StartVideoCallButton } from './Button';
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040025
simonf929a362022-11-18 16:53:45 -050026const ConversationView = () => {
simone35acc22022-12-02 16:51:12 -050027 const { conversationId } = useConversationContext();
idillon255682e2023-02-06 13:25:26 -050028 const { callData } = useCallManagerContext();
simone35acc22022-12-02 16:51:12 -050029
idillon255682e2023-02-06 13:25:26 -050030 if (callData?.conversationId === conversationId) {
simone35acc22022-12-02 16:51:12 -050031 return <CallInterface />;
32 }
33
idillonbef18a52022-09-01 01:51:40 -040034 return (
simon9f814a32022-11-22 21:40:53 -050035 <Stack flexGrow={1} height="100%">
simonf9d78f22022-11-25 15:47:15 -050036 <ConversationHeader />
idillonae655dd2022-10-14 18:11:02 -040037 <Divider
38 sx={{
39 borderTop: '1px solid #E5E5E5',
40 }}
41 />
simonf9d78f22022-11-25 15:47:15 -050042 <ChatInterface />
idillonbef18a52022-09-01 01:51:40 -040043 </Stack>
simond47ef9e2022-09-28 22:24:28 -040044 );
45};
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040046
simonf9d78f22022-11-25 15:47:15 -050047const ConversationHeader = () => {
idillon07d31cc2022-12-06 22:40:14 -050048 const { conversationId, conversationDisplayName } = useConversationContext();
idillon255682e2023-02-06 13:25:26 -050049 const { startCall } = useCallManagerContext();
idillonae655dd2022-10-14 18:11:02 -040050
51 return (
idillon6847e252022-11-04 11:50:08 -040052 <Stack direction="row" padding="16px" overflow="hidden">
idillonae655dd2022-10-14 18:11:02 -040053 <Stack flex={1} justifyContent="center" whiteSpace="nowrap" overflow="hidden">
54 <Typography variant="h3" textOverflow="ellipsis">
idillon07d31cc2022-12-06 22:40:14 -050055 {conversationDisplayName}
idillonae655dd2022-10-14 18:11:02 -040056 </Typography>
57 </Stack>
58 <Stack direction="row" spacing="20px">
idillon255682e2023-02-06 13:25:26 -050059 <StartAudioCallButton onClick={() => startCall(conversationId)} />
60 <StartVideoCallButton onClick={() => startCall(conversationId, true)} />
idillonae655dd2022-10-14 18:11:02 -040061 <AddParticipantButton />
62 <ShowOptionsMenuButton />
63 </Stack>
64 </Stack>
65 );
66};
67
simond47ef9e2022-09-28 22:24:28 -040068export default ConversationView;