agora-appbuilder-core 4.0.0-api.7 → 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 +2 -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 +2 -42
- package/template/src/subComponents/LocalEndCall.tsx +5 -52
- package/template/src/subComponents/LocalVideoMute.tsx +2 -45
- 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,8 +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 endCallEveryOne from '../src/utils/endCallEveryOne';
|
|
27
26
|
import TertiaryButton from '../src/atoms/TertiaryButton';
|
|
27
|
+
import useEndCall from '../src/utils/useEndCall';
|
|
28
28
|
export {
|
|
29
29
|
VideoRenderer,
|
|
30
30
|
DispatchContext,
|
|
@@ -47,6 +47,6 @@ export {
|
|
|
47
47
|
useRemoteMute,
|
|
48
48
|
MUTE_REMOTE_TYPE,
|
|
49
49
|
getCustomRoute,
|
|
50
|
-
endCallEveryOne,
|
|
51
50
|
TertiaryButton,
|
|
51
|
+
useEndCall,
|
|
52
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,55 +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
59
|
const {isToolbarMenuItem} = useToolbarMenu();
|
|
66
60
|
const {rtcProps} = useContext(PropsContext);
|
|
67
61
|
const {
|
|
68
62
|
data: {isHost},
|
|
69
63
|
} = useRoomInfo();
|
|
70
64
|
|
|
71
|
-
const isHostRef = useRef(isHost);
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
isHostRef.current = isHost;
|
|
74
|
-
}, [isHost]);
|
|
75
|
-
|
|
76
65
|
const {position} = useToolbar();
|
|
77
66
|
const local = useLocalUserInfo();
|
|
78
67
|
const isHandRaised = useIsHandRaised();
|
|
79
68
|
const localMute = useMuteToggleLocal();
|
|
80
69
|
const {isOnActionSheet, isOnFirstRow, showLabel} = useActionSheet();
|
|
81
70
|
const {showToolTip = false, disabled = false, showWarningIcon = true} = props;
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
events.on(controlMessageEnum.disableButton, async ({payload}) => {
|
|
85
|
-
try {
|
|
86
|
-
const data = JSON.parse(payload);
|
|
87
|
-
if (
|
|
88
|
-
data &&
|
|
89
|
-
data?.button === MUTE_REMOTE_TYPE.audio &&
|
|
90
|
-
!isHostRef.current
|
|
91
|
-
) {
|
|
92
|
-
if (data?.action === true) {
|
|
93
|
-
RtcEngineUnsafe.muteLocalAudioStream(true);
|
|
94
|
-
dispatch({
|
|
95
|
-
type: 'LocalMuteAudio',
|
|
96
|
-
value: [0, true],
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
dispatch({
|
|
100
|
-
type: 'LocalMuteAudio',
|
|
101
|
-
value: [0, false],
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} catch (error) {
|
|
106
|
-
console.log('debugging error on disableButton');
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}, []);
|
|
110
|
-
|
|
111
71
|
const micButtonLabel = useString<I18nDeviceStatus>(toolbarItemMicrophoneText);
|
|
112
72
|
const micButtonTooltip = useString<I18nDeviceStatus>(
|
|
113
73
|
toolbarItemMicrophoneTooltipText,
|
|
@@ -230,7 +190,7 @@ function LocalAudioMute(props: LocalAudioMuteProps) {
|
|
|
230
190
|
$config.EVENT_MODE &&
|
|
231
191
|
$config.RAISE_HAND &&
|
|
232
192
|
!isHost) ||
|
|
233
|
-
local.
|
|
193
|
+
local.audioBtnDisabled
|
|
234
194
|
) {
|
|
235
195
|
iconButtonProps.iconProps = {
|
|
236
196
|
...iconButtonProps.iconProps,
|
|
@@ -238,7 +198,7 @@ function LocalAudioMute(props: LocalAudioMuteProps) {
|
|
|
238
198
|
tintColor: $config.SEMANTIC_NEUTRAL,
|
|
239
199
|
};
|
|
240
200
|
iconButtonProps.toolTipMessage =
|
|
241
|
-
showToolTip && !local.
|
|
201
|
+
showToolTip && !local.audioBtnDisabled
|
|
242
202
|
? lstooltip(isHandRaised(local.uid))
|
|
243
203
|
: '';
|
|
244
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) {
|
|
@@ -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,9 +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
62
|
const {rtcProps} = useContext(PropsContext);
|
|
69
63
|
const {isScreenshareActive} = useScreenshare();
|
|
70
64
|
const {setShowStopScreenSharePopup} = useVideoCall();
|
|
@@ -73,47 +67,10 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
73
67
|
data: {isHost},
|
|
74
68
|
} = useRoomInfo();
|
|
75
69
|
|
|
76
|
-
const isHostRef = useRef(isHost);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
isHostRef.current = isHost;
|
|
79
|
-
}, [isHost]);
|
|
80
|
-
|
|
81
70
|
const local = useLocalUserInfo();
|
|
82
71
|
const isHandRaised = useIsHandRaised();
|
|
83
72
|
const localMute = useMuteToggleLocal();
|
|
84
73
|
const {showToolTip = false, disabled = false, showWarningIcon = true} = props;
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
events.on(controlMessageEnum.disableButton, async ({payload}) => {
|
|
88
|
-
try {
|
|
89
|
-
const data = JSON.parse(payload);
|
|
90
|
-
if (
|
|
91
|
-
data &&
|
|
92
|
-
data?.button === MUTE_REMOTE_TYPE.video &&
|
|
93
|
-
!isHostRef.current
|
|
94
|
-
) {
|
|
95
|
-
if (data?.action === true) {
|
|
96
|
-
isWebInternal()
|
|
97
|
-
? await RtcEngineUnsafe.muteLocalVideoStream(true)
|
|
98
|
-
: //@ts-ignore
|
|
99
|
-
await RtcEngineUnsafe.enableLocalVideo(false);
|
|
100
|
-
dispatch({
|
|
101
|
-
type: 'LocalMuteVideo',
|
|
102
|
-
value: [0, true],
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
dispatch({
|
|
106
|
-
type: 'LocalMuteVideo',
|
|
107
|
-
value: [0, false],
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.log('debugging error on disableButton');
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}, []);
|
|
116
|
-
|
|
117
74
|
const {isOnActionSheet, isOnFirstRow, showLabel} = useActionSheet();
|
|
118
75
|
const {position} = useToolbar();
|
|
119
76
|
const {
|
|
@@ -246,7 +203,7 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
246
203
|
$config.EVENT_MODE &&
|
|
247
204
|
$config.RAISE_HAND &&
|
|
248
205
|
!isHost) ||
|
|
249
|
-
local.
|
|
206
|
+
local.videoBtnDisabled
|
|
250
207
|
) {
|
|
251
208
|
iconButtonProps.iconProps = {
|
|
252
209
|
...iconButtonProps.iconProps,
|
|
@@ -254,7 +211,7 @@ function LocalVideoMute(props: LocalVideoMuteProps) {
|
|
|
254
211
|
tintColor: $config.SEMANTIC_NEUTRAL,
|
|
255
212
|
};
|
|
256
213
|
iconButtonProps.toolTipMessage =
|
|
257
|
-
showToolTip && !local.
|
|
214
|
+
showToolTip && !local.videoBtnDisabled
|
|
258
215
|
? lstooltip(isHandRaised(local.uid))
|
|
259
216
|
: '';
|
|
260
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;
|