agora-appbuilder-core 4.0.0-api.6 → 4.0.0-api.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/customization-api/temp.ts +4 -2
- package/template/customization-api/typeDefinition.ts +1 -2
- package/template/customization-api/utils.ts +1 -2
- package/template/src/components/ChatContext.ts +0 -2
- package/template/src/components/EventsConfigure.tsx +3 -18
- package/template/src/pages/VideoCall.tsx +7 -19
- package/template/src/subComponents/LocalAudioMute.tsx +3 -33
- package/template/src/subComponents/LocalEndCall.tsx +5 -52
- package/template/src/subComponents/LocalVideoMute.tsx +4 -36
- package/template/src/utils/useEndCall.ts +65 -0
- package/template/src/utils/useLocalAudio.ts +38 -0
- package/template/src/utils/endCallEveryOne.ts +0 -7
- package/template/src/utils/useDisableButton.tsx +0 -37
package/package.json
CHANGED
|
@@ -23,7 +23,8 @@ import {useToggleWhiteboard} from '../src/components/Controls';
|
|
|
23
23
|
import {ShowInputURL} from '../src/components/Share';
|
|
24
24
|
import useRemoteMute, {MUTE_REMOTE_TYPE} from '../src/utils/useRemoteMute';
|
|
25
25
|
import getCustomRoute from '../src/utils/getCustomRoute';
|
|
26
|
-
import
|
|
26
|
+
import TertiaryButton from '../src/atoms/TertiaryButton';
|
|
27
|
+
import useEndCall from '../src/utils/useEndCall';
|
|
27
28
|
export {
|
|
28
29
|
VideoRenderer,
|
|
29
30
|
DispatchContext,
|
|
@@ -46,5 +47,6 @@ export {
|
|
|
46
47
|
useRemoteMute,
|
|
47
48
|
MUTE_REMOTE_TYPE,
|
|
48
49
|
getCustomRoute,
|
|
49
|
-
|
|
50
|
+
TertiaryButton,
|
|
51
|
+
useEndCall,
|
|
50
52
|
};
|
|
@@ -103,8 +103,7 @@ export interface CustomRoutesInterface {
|
|
|
103
103
|
export type CustomHookType = () => () => Promise<void>;
|
|
104
104
|
export type EndCallHookType = () => (
|
|
105
105
|
isHost: boolean,
|
|
106
|
-
history
|
|
107
|
-
isTriggeredByHost?: boolean,
|
|
106
|
+
history: History,
|
|
108
107
|
) => Promise<void>;
|
|
109
108
|
|
|
110
109
|
export interface CustomizationApiInterface {
|
|
@@ -31,5 +31,4 @@ export {useHistory, useParams} from '../src/components/Router';
|
|
|
31
31
|
export {isWeb, isIOS, isAndroid, isDesktop} from '../src/utils/common';
|
|
32
32
|
export {default as isMobileOrTablet} from '../src/utils/isMobileOrTablet';
|
|
33
33
|
export {useLocalUid} from '../agora-rn-uikit';
|
|
34
|
-
|
|
35
|
-
export {default as useDisableButton} from '../src/utils/useDisableButton';
|
|
34
|
+
export {default as useLocalAudio} from '../src/utils/useLocalAudio';
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
waitingRoomApprovalRequiredToastSubHeading,
|
|
53
53
|
} from '../language/default-labels/videoCallScreenLabels';
|
|
54
54
|
import {useString} from '../utils/useString';
|
|
55
|
+
import useEndCall from '../utils/useEndCall';
|
|
55
56
|
|
|
56
57
|
interface Props {
|
|
57
58
|
children: React.ReactNode;
|
|
@@ -157,6 +158,7 @@ const EventsConfigure: React.FC<Props> = props => {
|
|
|
157
158
|
hostRemovedUserToastHeading,
|
|
158
159
|
)();
|
|
159
160
|
|
|
161
|
+
const executeEndCall = useEndCall();
|
|
160
162
|
const removedUserToastRef = useRef(hostRemovedUserToastHeadingTT);
|
|
161
163
|
|
|
162
164
|
useEffect(() => {
|
|
@@ -333,11 +335,6 @@ const EventsConfigure: React.FC<Props> = props => {
|
|
|
333
335
|
} catch (error) {
|
|
334
336
|
console.log('error on stop the screeshare', error);
|
|
335
337
|
}
|
|
336
|
-
|
|
337
|
-
if (!ENABLE_AUTH) {
|
|
338
|
-
// await authLogout();
|
|
339
|
-
await authLogin();
|
|
340
|
-
}
|
|
341
338
|
Toast.show({
|
|
342
339
|
leadingIconName: 'info',
|
|
343
340
|
type: 'info',
|
|
@@ -347,22 +344,10 @@ const EventsConfigure: React.FC<Props> = props => {
|
|
|
347
344
|
secondaryBtn: null,
|
|
348
345
|
});
|
|
349
346
|
setTimeout(() => {
|
|
350
|
-
|
|
351
|
-
type: 'EndCall',
|
|
352
|
-
value: [isHostRef.current, true],
|
|
353
|
-
});
|
|
347
|
+
executeEndCall();
|
|
354
348
|
}, 5000);
|
|
355
349
|
});
|
|
356
350
|
|
|
357
|
-
events.on(controlMessageEnum.endCallForEveryone, async () => {
|
|
358
|
-
setTimeout(() => {
|
|
359
|
-
dispatch({
|
|
360
|
-
type: 'EndCall',
|
|
361
|
-
value: [isHostRef.current, true],
|
|
362
|
-
});
|
|
363
|
-
}, 1000);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
351
|
events.on(controlMessageEnum.requestAudio, () => {
|
|
367
352
|
Toast.show({
|
|
368
353
|
leadingIconName: 'mic-on',
|
|
@@ -323,25 +323,13 @@ const VideoCall: React.FC = () => {
|
|
|
323
323
|
// SdkJoinState.promise?.res();
|
|
324
324
|
// }
|
|
325
325
|
// },
|
|
326
|
-
EndCall: (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
afterEndCall(isHost, history, isTriggeredByHost);
|
|
334
|
-
} catch (error) {
|
|
335
|
-
console.error('ERROR on useAfterEndCall hook', error);
|
|
336
|
-
}
|
|
337
|
-
}, 0);
|
|
338
|
-
} else {
|
|
339
|
-
setTimeout(() => {
|
|
340
|
-
// TODO: These callbacks are being called twice
|
|
341
|
-
SDKEvents.emit('leave');
|
|
342
|
-
history.push('/');
|
|
343
|
-
}, 0);
|
|
344
|
-
}
|
|
326
|
+
EndCall: () => {
|
|
327
|
+
clearState('join');
|
|
328
|
+
setTimeout(() => {
|
|
329
|
+
// TODO: These callbacks are being called twice
|
|
330
|
+
SDKEvents.emit('leave');
|
|
331
|
+
history.push('/');
|
|
332
|
+
}, 0);
|
|
345
333
|
},
|
|
346
334
|
UserJoined: (uid: UidType) => {
|
|
347
335
|
console.log('UIKIT Callback: UserJoined', uid);
|
|
@@ -39,9 +39,6 @@ import {
|
|
|
39
39
|
toolbarItemMicrophoneText,
|
|
40
40
|
toolbarItemMicrophoneTooltipText,
|
|
41
41
|
} from '../language/default-labels/videoCallScreenLabels';
|
|
42
|
-
import events from '../rtm-events-api';
|
|
43
|
-
import {controlMessageEnum} from '../components/ChatContext';
|
|
44
|
-
import {MUTE_REMOTE_TYPE} from '../utils/useRemoteMute';
|
|
45
42
|
|
|
46
43
|
/**
|
|
47
44
|
* A component to mute / unmute the local audio
|
|
@@ -59,45 +56,18 @@ export interface LocalAudioMuteProps {
|
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
function LocalAudioMute(props: LocalAudioMuteProps) {
|
|
62
|
-
const {dispatch} = useContext(DispatchContext);
|
|
63
|
-
const {RtcEngineUnsafe} = useContext(RtcContext);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
events.on(controlMessageEnum.disableButton, async ({payload}) => {
|
|
67
|
-
try {
|
|
68
|
-
const data = JSON.parse(payload);
|
|
69
|
-
if (data && data?.button === MUTE_REMOTE_TYPE.audio) {
|
|
70
|
-
if (data?.action === true) {
|
|
71
|
-
RtcEngineUnsafe.muteLocalAudioStream(true);
|
|
72
|
-
dispatch({
|
|
73
|
-
type: 'LocalMuteAudio',
|
|
74
|
-
value: [0, true],
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
dispatch({
|
|
78
|
-
type: 'LocalMuteAudio',
|
|
79
|
-
value: [0, false],
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.log('debugging error on disableButton');
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}, []);
|
|
88
|
-
|
|
89
59
|
const {isToolbarMenuItem} = useToolbarMenu();
|
|
90
60
|
const {rtcProps} = useContext(PropsContext);
|
|
91
61
|
const {
|
|
92
62
|
data: {isHost},
|
|
93
63
|
} = useRoomInfo();
|
|
64
|
+
|
|
94
65
|
const {position} = useToolbar();
|
|
95
66
|
const local = useLocalUserInfo();
|
|
96
67
|
const isHandRaised = useIsHandRaised();
|
|
97
68
|
const localMute = useMuteToggleLocal();
|
|
98
69
|
const {isOnActionSheet, isOnFirstRow, showLabel} = useActionSheet();
|
|
99
70
|
const {showToolTip = false, disabled = false, showWarningIcon = true} = props;
|
|
100
|
-
|
|
101
71
|
const micButtonLabel = useString<I18nDeviceStatus>(toolbarItemMicrophoneText);
|
|
102
72
|
const micButtonTooltip = useString<I18nDeviceStatus>(
|
|
103
73
|
toolbarItemMicrophoneTooltipText,
|
|
@@ -220,7 +190,7 @@ function LocalAudioMute(props: LocalAudioMuteProps) {
|
|
|
220
190
|
$config.EVENT_MODE &&
|
|
221
191
|
$config.RAISE_HAND &&
|
|
222
192
|
!isHost) ||
|
|
223
|
-
local.
|
|
193
|
+
local.audioBtnDisabled
|
|
224
194
|
) {
|
|
225
195
|
iconButtonProps.iconProps = {
|
|
226
196
|
...iconButtonProps.iconProps,
|
|
@@ -228,7 +198,7 @@ function LocalAudioMute(props: LocalAudioMuteProps) {
|
|
|
228
198
|
tintColor: $config.SEMANTIC_NEUTRAL,
|
|
229
199
|
};
|
|
230
200
|
iconButtonProps.toolTipMessage =
|
|
231
|
-
showToolTip && !local.
|
|
201
|
+
showToolTip && !local.audioBtnDisabled
|
|
232
202
|
? lstooltip(isHandRaised(local.uid))
|
|
233
203
|
: '';
|
|
234
204
|
iconButtonProps.disabled = true;
|
|
@@ -5,19 +5,13 @@ import {Prompt} from '../components/Router';
|
|
|
5
5
|
import IconButton, {IconButtonProps} from '../atoms/IconButton';
|
|
6
6
|
import ReactNativeForegroundService from '@supersami/rn-foreground-service';
|
|
7
7
|
import {Platform} from 'react-native';
|
|
8
|
-
import useSTTAPI from './caption/useSTTAPI';
|
|
9
|
-
import {useCaption} from './caption/useCaption';
|
|
10
8
|
import {useScreenshare} from './screenshare/useScreenshare';
|
|
11
|
-
import {DispatchContext, PropsContext} from '../../agora-rn-uikit';
|
|
12
9
|
import {useToolbarMenu} from '../utils/useMenu';
|
|
13
10
|
import ToolbarMenuItem from '../atoms/ToolbarMenuItem';
|
|
14
11
|
import {useActionSheet} from '../utils/useActionSheet';
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {useString} from '../../src/utils/useString';
|
|
19
|
-
import {toolbarItemLeaveText} from '../../src/language/default-labels/videoCallScreenLabels';
|
|
20
|
-
import {useCustomization} from 'customization-implementation';
|
|
12
|
+
import {useString} from '../utils/useString';
|
|
13
|
+
import {toolbarItemLeaveText} from '../language/default-labels/videoCallScreenLabels';
|
|
14
|
+
import useEndCall from '../utils/useEndCall';
|
|
21
15
|
|
|
22
16
|
export interface LocalEndcallProps {
|
|
23
17
|
render?: (onPress: () => void) => JSX.Element;
|
|
@@ -25,7 +19,7 @@ export interface LocalEndcallProps {
|
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
/* For android only, bg audio */
|
|
28
|
-
const stopForegroundService = () => {
|
|
22
|
+
export const stopForegroundService = () => {
|
|
29
23
|
if (Platform.OS === 'android') {
|
|
30
24
|
ReactNativeForegroundService.stop();
|
|
31
25
|
console.log('stopping foreground service');
|
|
@@ -34,56 +28,15 @@ const stopForegroundService = () => {
|
|
|
34
28
|
|
|
35
29
|
const LocalEndcall = (props: LocalEndcallProps) => {
|
|
36
30
|
const {isScreenshareActive, stopUserScreenShare} = useScreenshare();
|
|
37
|
-
const {
|
|
38
|
-
data: {isHost},
|
|
39
|
-
} = useRoomInfo();
|
|
40
31
|
const {isToolbarMenuItem} = useToolbarMenu();
|
|
41
|
-
const {dispatch} = useContext(DispatchContext);
|
|
42
32
|
const {isOnActionSheet, showLabel} = useActionSheet();
|
|
43
33
|
const endCallLabel = useString(toolbarItemLeaveText)();
|
|
44
|
-
const {defaultContent} = useContent();
|
|
45
34
|
const [endcallVisible, setEndcallVisible] = useState(false);
|
|
46
|
-
const {stop} = useSTTAPI();
|
|
47
|
-
const {isSTTActive} = useCaption();
|
|
48
35
|
const onPress = () => {
|
|
49
36
|
setEndcallVisible(true);
|
|
50
37
|
};
|
|
51
38
|
const [endCallState, setEndCallState] = useState(false);
|
|
52
|
-
const
|
|
53
|
-
const {authLogout, authLogin} = useAuth();
|
|
54
|
-
|
|
55
|
-
const beforeEndCall = useCustomization(
|
|
56
|
-
data =>
|
|
57
|
-
data?.lifecycle?.useBeforeEndCall && data?.lifecycle?.useBeforeEndCall(),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const executeEndCall = async () => {
|
|
61
|
-
if (beforeEndCall) {
|
|
62
|
-
try {
|
|
63
|
-
beforeEndCall(isHost);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error('ERROR on useBeforeEndCall hook', error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
dispatch({
|
|
70
|
-
type: 'EndCall',
|
|
71
|
-
value: [isHost, false],
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
// stopping foreground servie on end call
|
|
75
|
-
stopForegroundService();
|
|
76
|
-
// stopping STT on call end,if only last user is remaining in call
|
|
77
|
-
const usersInCall = Object.entries(defaultContent).filter(
|
|
78
|
-
item => item[1].type === 'rtc',
|
|
79
|
-
);
|
|
80
|
-
usersInCall.length === 1 && isSTTActive && stop();
|
|
81
|
-
RTMEngine.getInstance().engine.leaveChannel(rtcProps.channel);
|
|
82
|
-
if (!ENABLE_AUTH) {
|
|
83
|
-
// await authLogout();
|
|
84
|
-
await authLogin();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
39
|
+
const executeEndCall = useEndCall();
|
|
87
40
|
|
|
88
41
|
useEffect(() => {
|
|
89
42
|
if (!isScreenshareActive && endCallState) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
information visit https://appbuilder.agora.io.
|
|
10
10
|
*********************************************
|
|
11
11
|
*/
|
|
12
|
-
import React, {useContext, useEffect} from 'react';
|
|
12
|
+
import React, {useContext, useEffect, useRef} from 'react';
|
|
13
13
|
import {
|
|
14
14
|
ToggleState,
|
|
15
15
|
PermissionState,
|
|
@@ -42,9 +42,6 @@ import {
|
|
|
42
42
|
toolbarItemCameraText,
|
|
43
43
|
toolbarItemCameraTooltipText,
|
|
44
44
|
} from '../language/default-labels/videoCallScreenLabels';
|
|
45
|
-
import events from '../rtm-events-api';
|
|
46
|
-
import {controlMessageEnum} from '../components/ChatContext';
|
|
47
|
-
import {MUTE_REMOTE_TYPE} from '../utils/useRemoteMute';
|
|
48
45
|
|
|
49
46
|
/**
|
|
50
47
|
* A component to mute / unmute the local video
|
|
@@ -62,36 +59,6 @@ export interface LocalVideoMuteProps {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
65
|
-
const {dispatch} = useContext(DispatchContext);
|
|
66
|
-
const {RtcEngineUnsafe} = useContext(RtcContext);
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
events.on(controlMessageEnum.disableButton, async ({payload}) => {
|
|
70
|
-
try {
|
|
71
|
-
const data = JSON.parse(payload);
|
|
72
|
-
if (data && data?.button === MUTE_REMOTE_TYPE.video) {
|
|
73
|
-
if (data?.action === true) {
|
|
74
|
-
isWebInternal()
|
|
75
|
-
? await RtcEngineUnsafe.muteLocalVideoStream(true)
|
|
76
|
-
: //@ts-ignore
|
|
77
|
-
await RtcEngineUnsafe.enableLocalVideo(false);
|
|
78
|
-
dispatch({
|
|
79
|
-
type: 'LocalMuteVideo',
|
|
80
|
-
value: [0, true],
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
dispatch({
|
|
84
|
-
type: 'LocalMuteVideo',
|
|
85
|
-
value: [0, false],
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.log('debugging error on disableButton');
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}, []);
|
|
94
|
-
|
|
95
62
|
const {rtcProps} = useContext(PropsContext);
|
|
96
63
|
const {isScreenshareActive} = useScreenshare();
|
|
97
64
|
const {setShowStopScreenSharePopup} = useVideoCall();
|
|
@@ -99,6 +66,7 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
99
66
|
const {
|
|
100
67
|
data: {isHost},
|
|
101
68
|
} = useRoomInfo();
|
|
69
|
+
|
|
102
70
|
const local = useLocalUserInfo();
|
|
103
71
|
const isHandRaised = useIsHandRaised();
|
|
104
72
|
const localMute = useMuteToggleLocal();
|
|
@@ -235,7 +203,7 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
235
203
|
$config.EVENT_MODE &&
|
|
236
204
|
$config.RAISE_HAND &&
|
|
237
205
|
!isHost) ||
|
|
238
|
-
local.
|
|
206
|
+
local.videoBtnDisabled
|
|
239
207
|
) {
|
|
240
208
|
iconButtonProps.iconProps = {
|
|
241
209
|
...iconButtonProps.iconProps,
|
|
@@ -243,7 +211,7 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
243
211
|
tintColor: $config.SEMANTIC_NEUTRAL,
|
|
244
212
|
};
|
|
245
213
|
iconButtonProps.toolTipMessage =
|
|
246
|
-
showToolTip && !local.
|
|
214
|
+
showToolTip && !local.videoBtnDisabled
|
|
247
215
|
? lstooltip(isHandRaised(local.uid))
|
|
248
216
|
: '';
|
|
249
217
|
iconButtonProps.disabled = true;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {useContext} from 'react';
|
|
2
|
+
import {useCustomization} from 'customization-implementation';
|
|
3
|
+
import {useCaption, useContent, useRoomInfo} from 'customization-api';
|
|
4
|
+
import {PropsContext, DispatchContext} from '../../agora-rn-uikit';
|
|
5
|
+
import {useHistory} from '../components/Router';
|
|
6
|
+
import {stopForegroundService} from '../subComponents/LocalEndCall';
|
|
7
|
+
import RTMEngine from '../rtm/RTMEngine';
|
|
8
|
+
import {ENABLE_AUTH} from '../auth/config';
|
|
9
|
+
import {useAuth} from '../auth/AuthProvider';
|
|
10
|
+
|
|
11
|
+
const useEndCall = () => {
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
const {defaultContent} = useContent();
|
|
14
|
+
const {isSTTActive} = useCaption();
|
|
15
|
+
const {
|
|
16
|
+
data: {isHost},
|
|
17
|
+
} = useRoomInfo();
|
|
18
|
+
const {authLogin} = useAuth();
|
|
19
|
+
|
|
20
|
+
const {rtcProps} = useContext(PropsContext);
|
|
21
|
+
const {dispatch} = useContext(DispatchContext);
|
|
22
|
+
|
|
23
|
+
const beforeEndCall = useCustomization(
|
|
24
|
+
data =>
|
|
25
|
+
data?.lifecycle?.useBeforeEndCall && data?.lifecycle?.useBeforeEndCall(),
|
|
26
|
+
);
|
|
27
|
+
const afterEndCall = useCustomization(
|
|
28
|
+
data =>
|
|
29
|
+
data?.lifecycle?.useAfterEndCall && data?.lifecycle?.useAfterEndCall(),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return async () => {
|
|
33
|
+
try {
|
|
34
|
+
await beforeEndCall(isHost, history as unknown as History);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.log('debugging error on beforeEndCall');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
dispatch({
|
|
41
|
+
type: 'EndCall',
|
|
42
|
+
value: [],
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
// stopping foreground servie on end call
|
|
46
|
+
stopForegroundService();
|
|
47
|
+
// stopping STT on call end,if only last user is remaining in call
|
|
48
|
+
const usersInCall = Object.entries(defaultContent).filter(
|
|
49
|
+
item => item[1].type === 'rtc',
|
|
50
|
+
);
|
|
51
|
+
usersInCall.length === 1 && isSTTActive && stop();
|
|
52
|
+
RTMEngine.getInstance().engine.leaveChannel(rtcProps.channel);
|
|
53
|
+
if (!ENABLE_AUTH) {
|
|
54
|
+
// await authLogout();
|
|
55
|
+
await authLogin();
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await afterEndCall(isHost, history as unknown as History);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.log('debugging error on afterEndCall');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default useEndCall;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
********************************************
|
|
3
|
+
Copyright © 2021 Agora Lab, Inc., all rights reserved.
|
|
4
|
+
AppBuilder and all associated components, source code, APIs, services, and documentation
|
|
5
|
+
(the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
|
|
6
|
+
accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
|
|
7
|
+
Use without a license or in violation of any license terms and conditions (including use for
|
|
8
|
+
any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
|
|
9
|
+
information visit https://appbuilder.agora.io.
|
|
10
|
+
*********************************************
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {DispatchContext, RtcContext} from '../../agora-rn-uikit';
|
|
14
|
+
import {useContext} from 'react';
|
|
15
|
+
|
|
16
|
+
function useLocalAudio() {
|
|
17
|
+
const {dispatch} = useContext(DispatchContext);
|
|
18
|
+
const {RtcEngineUnsafe} = useContext(RtcContext);
|
|
19
|
+
|
|
20
|
+
const disableAudioButton = () => {
|
|
21
|
+
RtcEngineUnsafe.muteLocalAudioStream(true);
|
|
22
|
+
dispatch({
|
|
23
|
+
type: 'LocalMuteAudio',
|
|
24
|
+
value: [0, true],
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const enableAudioButton = () => {
|
|
29
|
+
dispatch({
|
|
30
|
+
type: 'LocalMuteAudio',
|
|
31
|
+
value: [0, false],
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return {enableAudioButton, disableAudioButton};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default useLocalAudio;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
********************************************
|
|
3
|
-
Copyright © 2021 Agora Lab, Inc., all rights reserved.
|
|
4
|
-
AppBuilder and all associated components, source code, APIs, services, and documentation
|
|
5
|
-
(the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
|
|
6
|
-
accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
|
|
7
|
-
Use without a license or in violation of any license terms and conditions (including use for
|
|
8
|
-
any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
|
|
9
|
-
information visit https://appbuilder.agora.io.
|
|
10
|
-
*********************************************
|
|
11
|
-
*/
|
|
12
|
-
import {useRoomInfo} from '../components/room-info/useRoomInfo';
|
|
13
|
-
import {controlMessageEnum} from '../components/ChatContext';
|
|
14
|
-
import events, {PersistanceLevel} from '../rtm-events-api';
|
|
15
|
-
import {MUTE_REMOTE_TYPE} from './useRemoteMute';
|
|
16
|
-
|
|
17
|
-
function useDisableButton() {
|
|
18
|
-
const {
|
|
19
|
-
data: {isHost},
|
|
20
|
-
} = useRoomInfo();
|
|
21
|
-
|
|
22
|
-
return async (type: MUTE_REMOTE_TYPE, action: boolean = true) => {
|
|
23
|
-
if (isHost) {
|
|
24
|
-
events.send(
|
|
25
|
-
controlMessageEnum.disableButton,
|
|
26
|
-
JSON.stringify({button: type, action}),
|
|
27
|
-
PersistanceLevel.None,
|
|
28
|
-
);
|
|
29
|
-
} else {
|
|
30
|
-
console.error(
|
|
31
|
-
'A host can only enable/disable participants video/audio button.',
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default useDisableButton;
|