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

[NEW] WebRTC-call in new tab for mobile devices #629

13 changes: 10 additions & 3 deletions src/components/Calls/CallIFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ import { createClassName } from '../helpers';
import styles from './styles.scss';


export const CallIframe = () => {
export const CallIframe = (props) => {
const { token, room } = store.state;
const url = `${ Livechat.client.host }/meet/${ room._id }?token=${ token }`;
const callInNewTab = async () => {
window.open(url);
await store.setState({ ongoingCall: { callStatus: 'ongoingCallInNewTab', time: props.time } });
await store.setState({ incomingCallAlert: { show: false, callProvider: props.callProvider } });
};
return (
<div className={createClassName(styles, 'call-iframe')}>
<iframe className={createClassName(styles, 'call-iframe__content')} allow='camera;microphone' src={url} />
<div>
{(window.innerWidth <= 800) && (window.innerHeight <= 630)
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
? <div className={createClassName(styles, 'call-iframe')}> <iframe className={createClassName(styles, 'call-iframe__content')} allow='camera;microphone' src={url} />
</div> : callInNewTab() }
</div>
);
};
2 changes: 1 addition & 1 deletion src/components/Calls/JoinCallButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const JoinCallButton = (props) => {
}
};
return (<div>
{ props.callStatus === 'accept'
{ props.callStatus === 'accept' || props.callStatus === 'ongoingCallInNewTab'
? <div className={createClassName(styles, 'joinCall')}>
<div className={createClassName(styles, 'joinCall__content')} >
<div className={createClassName(styles, 'joinCall__content-videoIcon')} >
Expand Down
6 changes: 5 additions & 1 deletion src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const processMessage = async (message) => {
closeChat(message);
} else if (message.t === 'command') {
commands[message.msg] && commands[message.msg]();
} else if (message.endTs && ((ongoingCall && ongoingCall.callStatus === 'declined') || incomingCallAlert)) {
} else if (message.endTs && ((ongoingCall && (ongoingCall.callStatus === 'declined' || ongoingCall.callStatus === 'ongoingCallInNewTab')) || incomingCallAlert)) {
await store.setState({ ongoingCall: { callStatus: 'ended', time: message.ts }, incomingCallAlert: null });
} else if (!incomingCallAlert && (message.t === constants.webrtcCallStartedMessageType || message.t === constants.jitsiCallStartedMessageType)) {
await processCallMessage(message);
Expand Down Expand Up @@ -209,6 +209,10 @@ export const loadMessages = async () => {
await store.setState({ ongoingCall: { callStatus: 'ended', time: lastMessage.ts }, incomingCallAlert: null });
return;
}
if (window.innerWidth <= 800 && window.innerHeight >= 630) {
await store.setState({ ongoingCall: { callStatus: 'ongoingCallInNewTab', time: lastMessage.ts }, incomingCallAlert: null });
return;
}
await processCallMessage(lastMessage);
}
}
Expand Down