Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6659653
add callnotification,msg,iframe code
Deepak-learner Jun 27, 2021
cbae6e8
fix eslint issues
Deepak-learner Jun 28, 2021
5d6fa88
fix eslint file path issues
Deepak-learner Jun 28, 2021
c60f527
fix stylelint issues
Deepak-learner Jun 28, 2021
9938609
done ui changes
Deepak-learner Jul 3, 2021
ca2b216
add join call button
Deepak-learner Jul 4, 2021
230f03a
add icons and improve ui
Deepak-learner Jul 6, 2021
5019468
fix error
Deepak-learner Jul 6, 2021
8e9199e
remove-icons
Deepak-learner Jul 6, 2021
e887911
add icons
Deepak-learner Jul 7, 2021
6890768
ui changes
Deepak-learner Jul 12, 2021
d537da6
Merge branch 'widget-calls' into widget-videocall-support
Deepak-learner Jul 12, 2021
cc2fef2
add icon and timeout functionality
Deepak-learner Jul 12, 2021
ac5ee06
add I18n.t
Deepak-learner Jul 12, 2021
3fa905d
add i18n.t, change classname, improve ui
Deepak-learner Jul 12, 2021
a4bd157
remove font-family
Deepak-learner Jul 13, 2021
8cc6eba
change iframe link
Deepak-learner Jul 13, 2021
a88e7ee
add button, changes css, change joincallbtn link
Deepak-learner Jul 14, 2021
31ce1d8
add check for jitsi
Deepak-learner Jul 14, 2021
ac5f8d4
add jitsi link
Deepak-learner Jul 15, 2021
a6799db
add time message in system message and add catch
Deepak-learner Jul 16, 2021
4754395
display alert, change function name
Deepak-learner Jul 16, 2021
3347ebd
Improve overall codebase
murtaza98 Jul 18, 2021
27b298c
Convert tabs to spaces for translation file
murtaza98 Jul 18, 2021
2a176ae
Accept jitsi url info from the message and remove dependency from Liv…
murtaza98 Jul 18, 2021
d101914
Update index.js
murtaza98 Jul 18, 2021
21992fc
add message in i18n file
Deepak-learner Jul 19, 2021
721de94
rebase
Deepak-learner Jul 21, 2021
13470be
add joincall btn, call time, timeout
Deepak-learner Jul 21, 2021
6cbd9a2
fix lint error
Deepak-learner Jul 21, 2021
158ab0c
Update ShowJoinCallButton.js
Deepak-learner Jul 22, 2021
8029eb1
Merge branch 'livechat-calls' into widget-videocall-support
Deepak-learner Jul 22, 2021
d013f18
Merge branch 'livechat-calls' of https://github.com/RocketChat/Rocket…
Deepak-learner Jul 22, 2021
66ce740
resolve issue
Deepak-learner Jul 22, 2021
c9985a6
update showjoincallbtn file
Deepak-learner Jul 22, 2021
3c8f8e5
fix conflicts
Deepak-learner Jul 22, 2021
89d6361
improve codebase
Deepak-learner Jul 27, 2021
930e387
fix bugs
Deepak-learner Aug 2, 2021
007fa16
add code for update call status
Deepak-learner Aug 3, 2021
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_video.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.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"markdown-it": "^11.0.0",
"mem": "^6.1.0",
"mitt": "^2.1.0",
"moment": "^2.29.1",
"preact": "^10.4.6",
"preact-i18nline": "^2.0.0",
"preact-router": "^3.2.1",
Expand Down
18 changes: 11 additions & 7 deletions src/components/Calls/CallIFrame.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { h } from 'preact';

import { Livechat } from '../../api';
import { Screen } from '../Screen';
import { createClassName } from '../helpers';
import styles from './styles.scss';


export const CallIFrame = (url) => (
<Screen.Content nopadding>
<div className={createClassName(styles, 'call-iframe')}>
<iframe className={createClassName(styles, 'call-iframe__content')} src={url} />
</div>
</Screen.Content>
);
export const CallIframe = (props) => {
const url = `${ Livechat.client.host }/meet/${ props.rid }`;
return (
<Screen.Content nopadding>
<div className={createClassName(styles, 'call-iframe')}>
<iframe className={createClassName(styles, 'call-iframe__content')} src={url} />
</div>
</Screen.Content>
);
};
50 changes: 28 additions & 22 deletions src/components/Calls/CallNotification.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { h } from 'preact';
import { useState } from 'preact/compat';

import { Livechat } from '../../api';
import I18n from '../../i18n';
import PhoneAccept from '../../icons/phone.svg';
import PhoneDecline from '../../icons/phoneOff.svg';
Expand All @@ -11,50 +12,55 @@ import { createClassName, getAvatarUrl } from '../helpers';
import styles from './styles.scss';


export const CallNotification = ({ callProvider, callerUsername, url, dispatch } = { callProvider: undefined, callerUsername: undefined, dispatch: undefined }) => {
const [show, setShow] = useState(!!callProvider && !!callerUsername && !!dispatch && !!url);
export const CallNotification = ({ callProvider, callerUsername, url, dispatch, time, rid } = { callProvider: undefined, callerUsername: undefined, dispatch: undefined, time: undefined }) => {
const [show, setShow] = useState(true);
console.log('asd', show);

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

await Livechat.updateCallStatus('inProgress', rid);
switch (callProvider) {
case constants.jitsiCallStartedMessageType: {
window.open(url);
await dispatch({ incomingCallAlert: null });
break;
}
case constants.webrtcCallStartedMessageType: {
// TODO: add webrtc code here
await dispatch({ ongoingCall: { callStatus: 'accept', time: { time } } });
break;
}
}
};

const declineClick = async () => {
await Livechat.updateCallStatus('declined', rid);
await dispatch({ incomingCallAlert: null });
await dispatch({ ongoingCall: { callStatus: 'decline', time: { time } } });
};

return (
<div className={createClassName(styles, 'call-notification')}>
<div>
{ show
? (
<div className={createClassName(styles, 'call-notification__content')}>
<div className={createClassName(styles, 'call-notification__content-avatar')}>
<Avatar
src={getAvatarUrl(callerUsername)}
large
/>
</div>
<div className={createClassName(styles, 'call-notification__content-message')}>
{ I18n.t('Incoming video Call') }
</div>
<div className={createClassName(styles, 'call-notification__content-actions')}>
<Button onClick={declineClick} className={createClassName(styles, 'call-notification__content-actions-accept')}>
<PhoneDecline width={20} height={20} /> <span style='margin-left:5px'> {I18n.t('Decline')} </span>
</Button>
<Button onClick={acceptClick} className={createClassName(styles, 'call-notification__content-actions-decline')} >
<PhoneAccept width={20} height={20} /><span style='margin-left:5px'> {I18n.t('Accept')} </span>
</Button>
<div className={createClassName(styles, 'call-notification')}>
<div className={createClassName(styles, 'call-notification__content')}>
<div className={createClassName(styles, 'call-notification__content-avatar')}>
<Avatar
src={getAvatarUrl(callerUsername)}
large
/>
</div>
<div className={createClassName(styles, 'call-notification__content-message')}>
{ I18n.t('Incoming video Call') }
</div>
<div className={createClassName(styles, 'call-notification__content-actions')}>
<Button onClick={declineClick} className={createClassName(styles, 'call-notification__content-actions-decline')}>
<PhoneDecline width={20} height={20} /> <span style='margin-left:5px'> {I18n.t('Decline')} </span>
</Button>
<Button onClick={acceptClick} className={createClassName(styles, 'call-notification__content-actions-accept')} >
<PhoneAccept width={20} height={20} /><span style='margin-left:5px'> {I18n.t('Accept')} </span>
</Button>
</div>
</div>
</div>
)
Expand Down
30 changes: 30 additions & 0 deletions src/components/Calls/CallTime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import moment from 'moment';
import { h } from 'preact';

import I18n from '../../i18n';
import { createClassName } from '../helpers';
import styles from './styles.scss';


export const CallTime = (props) => {
const hh = parseInt(Math.abs(props.endTime - props.time) / 36e5);
const mm = parseInt(Math.abs(props.endTime - props.time) / 6e4) % 60;
const ss = parseInt(Math.abs(props.endTime - props.time) / 1000) % 60;
let callDuration = '';
if (hh > 0) {
callDuration += `${ hh } hours ${ mm } minutes ${ ss } seconds.`;
} else if (mm > 0) {
callDuration += `${ mm } minutes ${ ss } seconds.`;
} else {
callDuration += `${ ss } seconds.`;
}
console.log('zer', callDuration);
const time = moment(props.endTime).format('h:mm A');
console.log('bdf', time);
return (
<div className={createClassName(styles, 'callTime')}>
{I18n.t('Call ended at %{time}', { time })}
{I18n.t(' - Lasted %{callDuration}', { callDuration })}
</div>
);
};
44 changes: 44 additions & 0 deletions src/components/Calls/JoinCallButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { h } from 'preact';

import { Livechat } from '../../api';
import I18n from '../../i18n';
import VideoIcon from '../../icons/video.svg';
import constants from '../../lib/constants';
import store from '../../store';
import { Button } from '../Button';
import { createClassName, createToken } from '../helpers';
import styles from './styles.scss';


export const JoinCallButton = (props) => {
const clickJoinCall = async () => {
const { alerts } = store.state;
switch (props.callProvider) {
case constants.jitsiCallStartedMessageType: {
window.open(props.url);
break;
}
case constants.webrtcCallStartedMessageType: {
// TODO: add webrtc code here
window.open(`${ Livechat.client.host }/meet/${ props.rid }`);
break;
}
default: {
const alert = { id: createToken(), children: I18n.t('Call already ended'), timeout: 5000 };
await store.setState({ alerts: (alerts.push(alert), alerts) });
}
}
};
return (<div>
{ props.callStatus === 'accept'
? <div className={createClassName(styles, 'joinCall')}>
<div className={createClassName(styles, 'joinCall__content')} >
<div className={createClassName(styles, 'joinCall__content-videoIcon')} >
<VideoIcon width={20} height={20} />
</div>
{I18n.t('Join my room to start the video call')}
</div>
<Button onClick={clickJoinCall} className={createClassName(styles, 'joinCall__content-action')}> <VideoIcon width={20} height={20} /> {I18n.t('Join Call')} </Button>
</div> : null } </div>
);
};
74 changes: 67 additions & 7 deletions src/components/Calls/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
.call-notification {
position: relative;

display: flex;

width: 100%;
height: 50%;

&__content {
display: flex;
flex-direction: column;

width: 100%;
height: 100%;
height: 200px;

background: #1f2329;

Expand Down Expand Up @@ -73,6 +68,71 @@
height: 50%;

&__content {
height: 100%;
width: 100%;
height: 200%;
}
}

.joinCall {
width: 300px;
margin: 15px;

padding: 5px;

border: 1px solid #e4e7ea;

&__content {
display: flex;
flex-direction: row;

padding: 15px;

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

&-videoIcon {
display: flex;

height: 7%;
margin-right: 10px;

padding: 5px;

border: 1px solid white;
background-color: #d1ebfe;
}

&-action {
display: block;

width: 120px;
margin-top: 0;
margin-bottom: 3%;
margin-left: 20%;
padding: 5px;

color: white;
border: 1px solid blue;
background-color: #1d74f5;
}
}
}

.callTime {
margin: 50px;

text-align: center;

color: #6c727a;

font-weight: 300;
}

@media screen and (min-width: 410px) {
.joinCall {
margin-left: 38%;
}
}
8 changes: 2 additions & 6 deletions src/components/Messages/Message/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h } from 'preact';

import I18n from '../../../i18n';
import { getAttachmentUrl, memo, normalizeTransferHistoryMessage, normalizeCallTimeMessage } from '../../helpers';
import { getAttachmentUrl, memo, normalizeTransferHistoryMessage } from '../../helpers';
import { AudioAttachment } from '../AudioAttachment';
import { FileAttachment } from '../FileAttachment';
import { ImageAttachment } from '../ImageAttachment';
Expand All @@ -22,8 +22,6 @@ import {
MESSAGE_TYPE_WELCOME,
MESSAGE_TYPE_LIVECHAT_CLOSED,
MESSAGE_TYPE_LIVECHAT_STARTED,
MESSAGE_WEBRTC_CALL,
MESSAGE_JITSI_CALL,
MESSAGE_TYPE_LIVECHAT_TRANSFER_HISTORY,
} from '../constants';

Expand Down Expand Up @@ -82,7 +80,7 @@ const renderContent = ({
),
].filter(Boolean);

const getSystemMessageText = ({ t, conversationFinishedMessage, transferData, callStatus }) =>
const getSystemMessageText = ({ t, conversationFinishedMessage, transferData }) =>
(t === MESSAGE_TYPE_ROOM_NAME_CHANGED && I18n.t('Room name changed'))
|| (t === MESSAGE_TYPE_USER_ADDED && I18n.t('User added by'))
|| (t === MESSAGE_TYPE_USER_REMOVED && I18n.t('User removed by'))
Expand All @@ -91,8 +89,6 @@ const getSystemMessageText = ({ t, conversationFinishedMessage, transferData, ca
|| (t === MESSAGE_TYPE_WELCOME && I18n.t('Welcome'))
|| (t === MESSAGE_TYPE_LIVECHAT_CLOSED && (conversationFinishedMessage || I18n.t('Conversation finished')))
|| (t === MESSAGE_TYPE_LIVECHAT_STARTED && I18n.t('Chat started'))
|| (t === MESSAGE_WEBRTC_CALL && normalizeCallTimeMessage(callStatus))
|| (t === MESSAGE_JITSI_CALL && normalizeCallTimeMessage(callStatus))
|| (t === MESSAGE_TYPE_LIVECHAT_TRANSFER_HISTORY && normalizeTransferHistoryMessage(transferData));

const getMessageUsernames = (compact, message) => {
Expand Down
19 changes: 18 additions & 1 deletion src/components/Messages/MessageList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { parseISO } from 'date-fns/fp';
import isSameDay from 'date-fns/isSameDay';
import { h } from 'preact';

import store from '../../../store';
import { CallTime } from '../../Calls/CallTime';
import { JoinCallButton } from '../../Calls/JoinCallButton';
import { createClassName, getAttachmentUrl, MemoizedComponent } from '../../helpers';
import { Message } from '../Message';
import { MessageSeparator } from '../MessageSeparator';
import { TypingIndicator } from '../TypingIndicator';
import styles from './styles.scss';


export class MessageList extends MemoizedComponent {
static defaultProps = {
typingUsernames: [],
Expand Down Expand Up @@ -111,6 +113,21 @@ export class MessageList extends MemoizedComponent {
const previousMessage = messages[i - 1];
const message = messages[i];
const nextMessage = messages[i + 1];
const { incomingCallAlert } = store.state;
const { ongoingCall } = store.state;

if (message.msg === 'Join my room to start the video call' && ongoingCall) {
const { url, callProvider, rid } = incomingCallAlert || '';
items.push(
<JoinCallButton callStatus={ongoingCall.callStatus} url={url} callProvider={callProvider} rid={rid} />,
);
}

if (message.endTs) {
items.push(
<CallTime time={parseISO(message.ts)} endTime={parseISO(message.endTs)} />,
);
}

const showDateSeparator = !previousMessage || !isSameDay(parseISO(message.ts), parseISO(previousMessage.ts));
if (showDateSeparator) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Messages/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const MESSAGE_TYPE_WELCOME = 'wm';
export const MESSAGE_TYPE_LIVECHAT_CLOSED = 'livechat-close';
export const MESSAGE_TYPE_LIVECHAT_STARTED = 'livechat-started';
export const MESSAGE_TYPE_LIVECHAT_TRANSFER_HISTORY = 'livechat_transfer_history';
export const MESSAGE_JITSI_CALL = 'webrtc_call_started';
export const MESSAGE_WEBRTC_CALL = 'jitsi_call_started';
export const MESSAGE_JITSI_CALL = 'jitsi_call_started';
export const MESSAGE_WEBRTC_CALL = 'livechat_webrtc_video_call';
Loading