Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

add callnotification,callStartmsg,iframe code #617

Merged
merged 21 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .loki/reference/chrome_Components_Icons_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .loki/reference/chrome_Components_Icons_phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/Messages/Message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import MessageBlocks from '../MessageBlocks';
import { MessageBubble } from '../MessageBubble';
import { MessageContainer } from '../MessageContainer';
import { MessageContent } from '../MessageContent';
import { ShowCallTime } from '../MessageList/livechatCall';
import { MessageText } from '../MessageText';
import { MessageTime } from '../MessageTime';
import { VideoAttachment } from '../VideoAttachment';
Expand Down Expand Up @@ -141,5 +142,6 @@ export const Message = memo(({
})}
</MessageContent>
{!compact && !message.t && <MessageTime normal={!me} inverse={me} ts={ts} />}
{message.t === 'jitsi_call_started' && message.callStatus === 'accept' ? <ShowCallTime stime={ts} /> : null}
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
</MessageContainer>
));
61 changes: 61 additions & 0 deletions src/components/Messages/MessageList/livechatCall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { h } from 'preact';
import { useState } from 'preact/compat';

import I18n from '../../../i18n';
import PhoneAccept from '../../../icons/phone.svg';
import PhoneDecline from '../../../icons/phoneOff.svg';
import { Avatar } from '../../Avatar';
import { Button } from '../../Button';
import { Screen } from '../../Screen';
import { createClassName, getAvatarUrl } from '../../helpers';
import { parseDate } from '../MessageTime/index';
import styles from './styles.scss';


const DisplayCallIframe = (rid) => (
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
<Screen.Content nopadding>
<div className={createClassName(styles, 'iframe')}>
<iframe style='height:100%' src='https://meet.jit.si/RocketChatXLKhe6QE6dyRLtTkX'{...rid} />
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</Screen.Content>
);


export const ShowCallTime = (props) => (
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
<div className={createClassName(styles, 'callTime')}>
<time
dateTime={new Date(props.stime).toISOString()}>
<div>{I18n.t('Call started at ')}{parseDate(props.stime)}</div>
</time>
</div>
);


export const CallNotification = (props) => {
const [isframe, setIframe] = useState(false);
const [show, setShow] = useState(true);

const acceptClick = () => {
setShow(!{ show });
setIframe(true);
};

const declineClick = () => {
setShow(false);
};

return (
<div>
{ show ? (<Screen.Content nopadding>
<div className={createClassName(styles, 'notifyCall')}>
<div className={createClassName(styles, 'avatar')}>
<Avatar
src={getAvatarUrl(props.rid.u.username)}
/></div>
{I18n.t('Incoming video Call')}
<div className={createClassName(styles, 'button')}>
<Button onClick={declineClick} className={createClassName(styles, 'declineButton')}> <PhoneDecline width={20} height={20} /> <span style='margin-left:5px'> {I18n.t('Decline')} </span> </Button>
<Button onClick={acceptClick} className={createClassName(styles, 'acceptButton')} > <PhoneAccept width={20} height={20} /> <span style='margin-left:5px'> {I18n.t('Accept')} </span> </Button></div></div></Screen.Content>) : null}
{isframe ? (<DisplayCallIframe session={props.rid} />) : null }
</div>);
};
94 changes: 94 additions & 0 deletions src/components/Messages/MessageList/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,97 @@
list-style: none;
}
}

.notifyCall {
position: absolute;
top: 0;

display: flex;
flex-direction: column;

width: 100%;
height: 50%;
margin-bottom: 5px;

padding-top: 40px;
padding-bottom: 0;

text-align: center;

color: #ffffff;

border: 1px solid black;

background: #1f2329;

font-size: 15px;
font-weight: 600;
font-style: normal;
line-height: 16px;
justify-content: space-between;
}

.callTime {
margin: 50px;

margin-left: 14%;

text-align: center;

color: #6c727a;

font-weight: 500;
}

.button {
display: flex;
flex-direction: row;

margin-bottom: 1px;
padding: 10px;
padding-top: 0;

color: white;
justify-content: center;
}

.avatar {
Deepak-learner marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
flex-direction: row;

margin-bottom: -17%;
justify-content: center;
}

.declineButton {
margin-right: 10px;
margin-bottom: 0;

border-color: red;
background-color: #f5455c;
}

.acceptButton {
margin-bottom: 0;
margin-left: 10px;

border-color: green;
background-color: #2de0a5;
}

.iframe {
position: absolute;
top: 0;

display: flex;
flex-direction: column;

width: 100%;
height: 50%;
}

@media screen and (min-width: 410px) {
.avatar {
margin-bottom: -7%;
}
}
6 changes: 6 additions & 0 deletions src/icons/phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/icons/phoneOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ Livechat.onMessage(async (message) => {
message.ts = message.ts.toISOString();
}

if (message.t === 'jitsi_call_started') {
message.callStatus = 'accept';
}

message = await normalizeMessage(message);
if (!message) {
return;
Expand Down
4 changes: 4 additions & 0 deletions src/routes/Chat/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FilesDropTarget } from '../../components/FilesDropTarget';
import { FooterOptions, CharCounter } from '../../components/Footer';
import { Menu } from '../../components/Menu';
import { MessageList } from '../../components/Messages';
import { CallNotification } from '../../components/Messages/MessageList/livechatCall';
import { Screen } from '../../components/Screen';
import { createClassName } from '../../components/helpers';
import I18n from '../../i18n';
Expand Down Expand Up @@ -165,6 +166,9 @@ export default class Chat extends Component {
autoFocus={true}
/>}
</div>
<div>
{(messages[messages.length - 1] ? messages[messages.length - 1].t === 'jitsi_call_started' : messages[messages.length - 1]) ? <CallNotification rid={(messages[messages.length - 1])} /> : null}
Deepak-learner marked this conversation as resolved.
Show resolved Hide resolved
</div>
</Screen.Content>
<Screen.Footer
options={options ? (
Expand Down