|
@@ -6,49 +6,56 @@ import 'react-native-gesture-handler';
|
6
|
6
|
import 'react-native-get-random-values';
|
7
|
7
|
import './react/features/mobile/polyfills';
|
8
|
8
|
|
9
|
|
-// @ts-ignore
|
10
|
9
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
11
|
|
-import { View } from 'react-native';
|
|
10
|
+import { View, ViewStyle } from 'react-native';
|
12
|
11
|
|
13
|
12
|
import { appNavigate } from './react/features/app/actions.native';
|
14
|
13
|
import { App } from './react/features/app/components/App.native';
|
15
|
14
|
import { setAudioMuted, setVideoMuted } from './react/features/base/media/actions';
|
16
|
|
-// @ts-ignore
|
17
|
15
|
import JitsiThemePaperProvider from './react/features/base/ui/components/JitsiThemeProvider.native';
|
18
|
16
|
|
19
|
17
|
|
|
18
|
+interface IEventListeners {
|
|
19
|
+ onConferenceJoined?: Function;
|
|
20
|
+ onConferenceLeft?: Function;
|
|
21
|
+ onConferenceWillJoin?: Function;
|
|
22
|
+ onParticipantJoined?: Function;
|
|
23
|
+ onReadyToClose?: Function;
|
|
24
|
+}
|
|
25
|
+
|
20
|
26
|
interface IUserInfo {
|
21
|
|
- email: string,
|
22
|
|
- displayName: string;
|
23
|
27
|
avatarURL: string;
|
|
28
|
+ displayName: string;
|
|
29
|
+ email: string;
|
24
|
30
|
}
|
25
|
31
|
|
26
|
32
|
interface IAppProps {
|
|
33
|
+ config: object;
|
27
|
34
|
flags: object;
|
28
|
|
- meetingOptions: {
|
29
|
|
- domain: string;
|
30
|
|
- roomName: string;
|
31
|
|
- onReadyToClose?: Function;
|
32
|
|
- onConferenceJoined?: Function;
|
33
|
|
- onConferenceWillJoin?: Function;
|
34
|
|
- onConferenceLeft?: Function;
|
35
|
|
- onParticipantJoined?: Function;
|
36
|
|
- settings?: {
|
37
|
|
- startWithAudioMuted?: boolean;
|
38
|
|
- startAudioOnly?: boolean;
|
39
|
|
- startWithVideoMuted?: boolean;
|
40
|
|
- },
|
41
|
|
- userInfo: IUserInfo
|
42
|
|
- };
|
|
35
|
+ eventListeners: IEventListeners;
|
|
36
|
+ room: string;
|
|
37
|
+ serverURL?: string;
|
43
|
38
|
style?: Object;
|
|
39
|
+ token?: string;
|
|
40
|
+ userInfo?: IUserInfo;
|
44
|
41
|
}
|
45
|
42
|
|
46
|
43
|
/**
|
47
|
44
|
* Main React Native SDK component that displays a Jitsi Meet conference and gets all required params as props
|
48
|
45
|
*/
|
49
|
|
-export const JitsiMeeting = forwardRef(({ flags, meetingOptions, style }: IAppProps, ref) => {
|
|
46
|
+export const JitsiMeeting = forwardRef((props: IAppProps, ref) => {
|
50
|
47
|
const [ appProps, setAppProps ] = useState({});
|
51
|
48
|
const app = useRef(null);
|
|
49
|
+ const {
|
|
50
|
+ config,
|
|
51
|
+ eventListeners,
|
|
52
|
+ flags,
|
|
53
|
+ room,
|
|
54
|
+ serverURL,
|
|
55
|
+ style,
|
|
56
|
+ token,
|
|
57
|
+ userInfo
|
|
58
|
+ } = props;
|
52
|
59
|
|
53
|
60
|
// eslint-disable-next-line arrow-body-style
|
54
|
61
|
useImperativeHandle(ref, () => ({
|
|
@@ -71,32 +78,44 @@ export const JitsiMeeting = forwardRef(({ flags, meetingOptions, style }: IAppPr
|
71
|
78
|
|
72
|
79
|
useEffect(
|
73
|
80
|
() => {
|
74
|
|
- const url = `${meetingOptions.domain}/${meetingOptions.roomName}`;
|
|
81
|
+ const urlObj = {
|
|
82
|
+ config,
|
|
83
|
+ jwt: token
|
|
84
|
+ };
|
|
85
|
+
|
|
86
|
+ let urlProps;
|
|
87
|
+
|
|
88
|
+ if (room.includes('://')) {
|
|
89
|
+ urlProps = {
|
|
90
|
+ ...urlObj,
|
|
91
|
+ url: room
|
|
92
|
+ };
|
|
93
|
+ } else {
|
|
94
|
+ urlProps = {
|
|
95
|
+ ...urlObj,
|
|
96
|
+ room,
|
|
97
|
+ serverURL
|
|
98
|
+ };
|
|
99
|
+ }
|
75
|
100
|
|
76
|
101
|
setAppProps({
|
77
|
|
- 'url': {
|
78
|
|
- url,
|
79
|
|
- config: meetingOptions.settings
|
80
|
|
- },
|
|
102
|
+ 'flags': flags,
|
81
|
103
|
'rnSdkHandlers': {
|
82
|
|
- onReadyToClose: meetingOptions.onReadyToClose,
|
83
|
|
- onConferenceJoined: meetingOptions.onConferenceJoined,
|
84
|
|
- onConferenceWillJoin: meetingOptions.onConferenceWillJoin,
|
85
|
|
- onConferenceLeft: meetingOptions.onConferenceLeft,
|
86
|
|
- onParticipantJoined: meetingOptions.onParticipantJoined
|
|
104
|
+ onReadyToClose: eventListeners.onReadyToClose,
|
|
105
|
+ onConferenceJoined: eventListeners.onConferenceJoined,
|
|
106
|
+ onConferenceWillJoin: eventListeners.onConferenceWillJoin,
|
|
107
|
+ onConferenceLeft: eventListeners.onConferenceLeft,
|
|
108
|
+ onParticipantJoined: eventListeners.onParticipantJoined
|
87
|
109
|
},
|
88
|
|
- 'flags': { ...flags },
|
89
|
|
- 'userInfo': {
|
90
|
|
- ...meetingOptions.userInfo
|
91
|
|
- }
|
|
110
|
+ 'url': urlProps,
|
|
111
|
+ 'userInfo': userInfo
|
92
|
112
|
});
|
93
|
113
|
}, []
|
94
|
114
|
);
|
95
|
115
|
|
96
|
116
|
return (
|
97
|
|
- <View style = { style }>
|
|
117
|
+ <View style = { style as ViewStyle }>
|
98
|
118
|
<JitsiThemePaperProvider>
|
99
|
|
- {/* @ts-ignore */}
|
100
|
119
|
<App
|
101
|
120
|
{ ...appProps }
|
102
|
121
|
ref = { app } />
|