Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
technophilic committed Oct 1, 2020
2 parents dc52ea4 + ed9edde commit a82be34
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 66 deletions.
2 changes: 1 addition & 1 deletion electron/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {app, BrowserWindow, session} = require('electron');
const path = require('path');
const isDevelopment = process.env.NODE_ENV === 'development';
const {format} = require('url');
const {devServer: {port} = {}} = require('../../webpack.renderer.config');
const port = 9002;

// isDevelopment && require('react-devtools-electron');
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
Expand Down
30 changes: 18 additions & 12 deletions src/components/ParticipantsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ColorContext from '../components/ColorContext';
import {useParams} from './Router';
import {gql, useQuery} from '@apollo/client';
import icons from '../assets/icons';
import platform from '../subComponents/Platform';

const SHARE = gql`
query share($passphrase: String!) {
Expand All @@ -47,21 +48,26 @@ const ParticipantView = (props: any) => {
variables: {passphrase: phrase},
});
const copyToClipboard = () => {
console.log(data, loading, error);
if (data && !loading) {
console.log(data.share);
Clipboard.setString(
data.share.pstn
? `Meeting - ${data.share.title}
let stringToCopy = '';
$config.frontEndURL
? (stringToCopy += `Meeting - ${data.share.title}
URL for Attendee: ${$config.frontEndURL}/${data.share.passphrase.view}
URL for Host: ${$config.frontEndURL}/${data.share.passphrase.host}
URL for Host: ${$config.frontEndURL}/${data.share.passphrase.host}`)
: platform === 'web'
? (stringToCopy += `Meeting - ${data.share.title}
URL for Attendee: ${window.location.origin}/${data.share.passphrase.view}
URL for Host: ${window.location.origin}/${data.share.passphrase.host}`)
: (stringToCopy += `Meeting - ${data.share.title}
Attendee Meeting ID: ${data.share.passphrase.view}
Host Meeting ID: ${data.share.passphrase.host}`);

PSTN Number: ${data.share.pstn.number}
PSTN Pin: ${data.share.pstn.dtmf}`
: `Meeting - ${data.share.title}
URL for Attendee: ${$config.frontEndURL}/${data.share.passphrase.view}
URL for Host: ${$config.frontEndURL}/${data.share.passphrase.host}`,
);
data.share.pstn
? (stringToCopy += `PSTN Number: ${data.share.pstn.number}
PSTN Pin: ${data.share.pstn.dtmf}`)
: '';
console.log(stringToCopy);
Clipboard.setString(stringToCopy);
}
};

Expand Down
48 changes: 47 additions & 1 deletion src/components/Precall.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import {
import LocalUserContext from '../../agora-rn-uikit/src/LocalUserContext';
import RtcContext from '../../agora-rn-uikit/src/RtcContext';
import ColorContext from '../components/ColorContext';
import {useHistory} from './Router';

const Precall = (props: any) => {
const history = useHistory();
const {primaryColor} = useContext(ColorContext);
const maxUsers = useContext(MaxUidContext);
const rtc = useContext(RtcContext);
rtc.RtcEngine.startPreview();
const {setCallActive, queryComplete, username, setUsername} = props;
const {setCallActive, queryComplete, username, setUsername, error} = props;
return (
<ImageBackground
source={{uri: $config.bg}}
Expand All @@ -32,6 +34,50 @@ const Precall = (props: any) => {
<View style={style.heading}>
<Text style={style.headingText}>Precall </Text>
</View>
{error ? (
<View
style={{
position: 'absolute',
borderWidth: 2,
borderColor: '#ff0000',
backgroundColor: '#ffffff80',
paddingHorizontal: 10,
paddingVertical: 2,
maxWidth: 250,
width: '65%',
left: 0,
right: 0,
top: '10%',
marginHorizontal: 'auto',
left: '20%',
zIndex: 55,
}}>
<Text style={{alignSelf: 'center'}}>
<Text
style={{
fontWeight: '500',
textAlign: 'center',
fontSize: 16,
}}>
{error.name + ' - '}
</Text>
<Text style={{}}>{error.message}</Text>
</Text>
<TouchableOpacity
style={{alignSelf: 'center'}}
onPress={() => history.replace('./')}>
<Text
style={{
fontWeight: '500',
textDecorationLine: 'underline',
}}>
{'Go back '}
</Text>
</TouchableOpacity>
</View>
) : (
<></>
)}
<View style={style.full}>
<MaxVideoView user={maxUsers[0]} key={maxUsers[0].uid} />
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Precall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ const Precall = (props: any) => {
textAlign: 'center',
textDecorationLine: 'underline',
}}>
Try Again
Go back
</Text>
</TouchableOpacity>
</View>
) : (
<></>
)}
<OpenInNativeButton />
{/* <OpenInNativeButton /> */}
</View>
<View style={style.content}>
<View style={style.leftContent}>
Expand Down
75 changes: 51 additions & 24 deletions src/components/Share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ColorContext from '../components/ColorContext';
import {useHistory} from './Router';
import Clipboard from '../subComponents/Clipboard';
import Illustration from '../subComponents/Illustration';

import platform from '../subComponents/Platform';
const Share = (props: any) => {
const history = useHistory();
const {
Expand All @@ -30,27 +30,34 @@ const Share = (props: any) => {
};

const copyToClipboard = () => {
Clipboard.setString(
pstn
? hostControlCheckbox
? `Meeting - ${roomTitle}
URL for Attendee: ${urlView}
URL for Host: ${urlHost}
let stringToCopy = '';

PSTN Number: ${pstn.number}
PSTN Pin: ${pstn.dtmf}`
: `Meeting - ${roomTitle}
Meeting URL: ${urlHost}
$config.frontEndURL
? hostControlCheckbox
? (stringToCopy += `Meeting - ${roomTitle}
URL for Attendee: ${$config.frontEndURL}/${urlView}
URL for Host: ${$config.frontEndURL}/${urlHost}`)
: (stringToCopy += `Meeting - ${roomTitle}
Meeting URL: ${$config.frontEndURL}/${urlHost}`)
: platform === 'web'
? hostControlCheckbox
? (stringToCopy += `Meeting - ${roomTitle}
URL for Attendee: ${window.location.origin}/${urlView}
URL for Host: ${window.location.origin}/${urlHost}`)
: (stringToCopy += `Meeting - ${roomTitle}
Meeting URL: ${window.location.origin}/${urlHost}`)
: hostControlCheckbox
? (stringToCopy += `Meeting - ${roomTitle}
Attendee Meeting ID: ${urlView}
Host Meeting ID: ${urlHost}`)
: (stringToCopy += `Meeting - ${roomTitle}
Meeting URL: ${urlHost}`);

PSTN Number: ${pstn.number}
PSTN Pin: ${pstn.dtmf}`
: hostControlCheckbox
? `Meeting - ${roomTitle}
URL for Attendee: ${urlView}
URL for Host: ${urlHost}`
: `Meeting - ${roomTitle}
Meeting URL: ${urlHost}`,
);
pstn
? (stringToCopy += `PSTN Number: ${pstn.number}
PSTN Pin: ${pstn.dtmf}`)
: '';
Clipboard.setString(stringToCopy);
};

const [dim, setDim] = useState([
Expand All @@ -68,19 +75,39 @@ Meeting URL: ${urlHost}`,
<Text style={style.heading}>Meeting Created</Text>
{hostControlCheckbox ? (
<>
<Text style={style.urlTitle}>URL for Attendee:</Text>
<Text style={style.urlTitle}>
{!$config.frontEndURL && platform !== 'web'
? 'Attendee Meeting ID:'
: 'URL for Attendee:'}
</Text>
<View style={style.urlHolder}>
<Text style={style.url}>{urlView}</Text>
<Text style={style.url}>
{$config.frontEndURL
? `${$config.frontEndURL}/${urlView}`
: platform === 'web'
? `${window.location.origin}/${urlView}`
: urlView}
</Text>
</View>
</>
) : (
<></>
)}
<Text style={style.urlTitle}>
{hostControlCheckbox ? 'URL for Host:' : 'Meeting URL'}
{hostControlCheckbox
? !$config.frontEndURL && platform !== 'web'
? 'Host Meeting ID:'
: 'URL for Host:'
: 'Meeting URL'}
</Text>
<View style={style.urlHolder}>
<Text style={style.url}>{urlHost}</Text>
<Text style={style.url}>
{$config.frontEndURL
? `${$config.frontEndURL}/${urlHost}`
: platform === 'web'
? `${window.location.origin}/${urlHost}`
: urlHost}
</Text>
</View>
{pstn ? (
<View style={style.pstnHolder}>
Expand Down
8 changes: 3 additions & 5 deletions src/components/styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {Platform, Dimensions} from 'react-native';

const {width} = Dimensions.get('window');
import {Platform} from 'react-native';

const styles = {
temp: {
Expand All @@ -19,7 +17,7 @@ const styles = {
bottom: 0,
},
localButton: {
backgroundColor: '#fff',
backgroundColor: '#ffffff00',
borderRadius: 2,
borderColor: $config.primaryColor,
borderWidth: 0,
Expand All @@ -31,7 +29,7 @@ const styles = {
justifyContent: 'center',
},
endCall: {
backgroundColor: '#fff',
backgroundColor: '#ffffff00',
borderRadius: 2,
borderColor: $config.primaryColor,
borderWidth: 0,
Expand Down
10 changes: 3 additions & 7 deletions src/pages/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ const Create = () => {
})
.then((res: any) => {
console.log('promise data', res);
setUrlView(
`${$config.frontEndURL}/${res.data.createChannel.passphrase.view}`,
);
setUrlHost(
`${$config.frontEndURL}/${res.data.createChannel.passphrase.host}`,
);
setUrlView(res.data.createChannel.passphrase.view);
setUrlHost(res.data.createChannel.passphrase.host);
setPstn(res.data.createChannel.pstn);
setJoinPhrase(res.data.createChannel.passphrase.host);
// setPstnPin(res.data.createChannel.pstn.)
Expand Down Expand Up @@ -126,7 +122,7 @@ const Create = () => {
) : (
<></>
)}
<OpenInNativeButton />
{/* <OpenInNativeButton /> */}
</View>
{!roomCreated ? (
<View style={style.content} onLayout={onLayout}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Join = (props: joinProps) => {
) : (
<></>
)}
<OpenInNativeButton />
{/* <OpenInNativeButton /> */}
</View>
<View style={style.content}>
<View style={style.leftContent}>
Expand Down
5 changes: 1 addition & 4 deletions src/subComponents/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useContext } from 'react';
import React from 'react';
import {Image, TouchableOpacity} from 'react-native';
import {useHistory} from '../components/Router';
import colorContext from '../components/ColorContext';

export default function Logo() {
const history = useHistory();
const {primaryColor} = useContext(colorContext);

return (
<TouchableOpacity onPress={() => history.replace('/')}>
Expand All @@ -14,7 +12,6 @@ export default function Logo() {
style={{
width: 90,
height: 30,
tintColor: primaryColor,
}}
resizeMode="contain"
/>
Expand Down
13 changes: 5 additions & 8 deletions src/subComponents/LogoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ const LogoutButton = (props: any) => {
const [logoutQuery] = useMutation(LOGOUT);

const logout = () => {
logoutQuery({variables: {token}})
.then(() => {
setStore({token: null});
})
.catch((e) => {
setError(e);
console.log(e);
});
setStore({token: null});
logoutQuery({variables: {token}}).catch((e) => {
// setError(e);
console.log(e);
});
};

const login = () => {
Expand Down
2 changes: 2 additions & 0 deletions src/subComponents/Platform.electron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const platform = 'electron';
export default platform;
2 changes: 2 additions & 0 deletions src/subComponents/Platform.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const platform = 'native';
export default platform;
2 changes: 2 additions & 0 deletions src/subComponents/Platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const platform = 'web';
export default platform;
9 changes: 8 additions & 1 deletion webpack.commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ module.exports = {
isTSX: true,
},
],
'@babel/preset-env', // smartly transforms js into es5-es6
[
'@babel/preset-env', // smartly transforms js into es5-es6
isElectron && {
targets: {
node: 'current',
},
},
].filter(Boolean),
],
plugins: [
// Adds support for class properties
Expand Down

0 comments on commit a82be34

Please sign in to comment.