agora-appbuilder-core 2.2.0 → 2.3.0-beta.2
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/Readme.md +7 -1
- package/package.json +4 -3
- package/template/Gulpfile.js +306 -87
- package/template/_gitignore +4 -1
- package/template/_package-lock.json +32186 -3078
- package/template/agora-rn-uikit/src/AgoraUIKit.tsx +23 -20
- package/template/agora-rn-uikit/src/Contexts/LocalUserContext.tsx +13 -8
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +25 -9
- package/template/agora-rn-uikit/src/Contexts/RenderContext.tsx +10 -0
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +11 -5
- package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +6 -2
- package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +1 -1
- package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +6 -2
- package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +2 -2
- package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +2 -2
- package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +6 -2
- package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +11 -6
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteAudioMute.tsx +10 -6
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteSwap.tsx +7 -6
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteVideoMute.tsx +6 -5
- package/template/agora-rn-uikit/src/Controls/RemoteControls.tsx +3 -3
- package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +16 -13
- package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +16 -13
- package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +13 -13
- package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +16 -13
- package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +28 -31
- package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +48 -35
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +11 -13
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +11 -13
- package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +18 -15
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +14 -2
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +19 -3
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +161 -44
- package/template/agora-rn-uikit/src/Utils/useLocalUid.ts +8 -0
- package/template/agora-rn-uikit/src/Views/MaxVideoView.native.tsx +8 -6
- package/template/agora-rn-uikit/src/Views/MaxVideoView.tsx +8 -6
- package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +18 -9
- package/template/agora-rn-uikit/src/index.ts +12 -12
- package/template/babel.config.js +17 -1
- package/template/bridge/rtc/webNg/RtcEngine.ts +34 -28
- package/template/bridge/rtc/webNg/SurfaceView.tsx +3 -2
- package/template/bridge/rtc/webNg/Types.ts +14 -0
- package/template/bridge/rtc/webNg/index.ts +5 -2
- package/template/bridge/rtm/web/index.ts +13 -7
- package/template/electron-builder.js +3 -2
- package/template/esbuild.rsdk.go +226 -0
- package/template/{src/subComponents/LayoutEnum.tsx → esbuildConfigTransform.js} +1 -5
- package/template/fpe-api/components.ts +42 -0
- package/template/fpe-api/context.ts +45 -0
- package/template/fpe-api/fpeEvents.ts +9 -0
- package/template/fpe-api/index.ts +21 -0
- package/template/fpe-api/install.ts +128 -0
- package/template/fpe-api/typeDefinition.ts +143 -0
- package/template/fpe-api/useFpe.tsx +35 -0
- package/template/fpe-api/utils.ts +62 -0
- package/template/fpe-implementation/createHook.ts +33 -0
- package/template/fpe-implementation/dummyFpe.ts +17 -0
- package/template/fpe-implementation/index.ts +1 -0
- package/template/fpe-todo.txt +14 -0
- package/template/fpe.config.js +29 -0
- package/template/global.d.ts +4 -0
- package/template/index.rsdk.tsx +27 -0
- package/template/index.wsdk.tsx +27 -0
- package/template/package.json +28 -12
- package/template/react-native-toast-message/src/index.js +9 -10
- package/template/react-native-toast-message/src/index.wsdk.js +419 -0
- package/template/src/App.tsx +97 -65
- package/template/src/AppWrapper.tsx +79 -0
- package/template/src/SDKAppWrapper.tsx +67 -0
- package/template/src/atoms/PrimaryButton.tsx +14 -8
- package/template/src/atoms/TextInput.tsx +13 -5
- package/template/src/components/Chat.tsx +171 -139
- package/template/src/components/ChatContext.ts +14 -22
- package/template/src/components/ColorConfigure.tsx +2 -2
- package/template/src/components/Controls.native.tsx +72 -62
- package/template/src/components/Controls.tsx +90 -69
- package/template/src/components/DeviceConfigure.tsx +1 -1
- package/template/src/components/DeviceContext.tsx +14 -7
- package/template/src/components/GraphQLProvider.tsx +9 -2
- package/template/src/components/GridVideo.tsx +20 -159
- package/template/src/components/HostControlView.tsx +54 -15
- package/template/src/components/Navbar.tsx +408 -157
- package/template/src/components/NetworkQualityContext.tsx +29 -22
- package/template/src/components/ParticipantsView.tsx +91 -115
- package/template/src/components/PinnedVideo.tsx +41 -188
- package/template/src/components/Precall.native.tsx +131 -97
- package/template/src/components/Precall.tsx +193 -158
- package/template/src/components/RTMConfigure.tsx +328 -416
- package/template/src/components/Router.sdk.ts +20 -0
- package/template/src/components/SessionContext.tsx +6 -3
- package/template/src/components/Settings.native.tsx +3 -0
- package/template/src/components/Settings.tsx +65 -31
- package/template/src/components/SettingsView.tsx +14 -8
- package/template/src/components/Share.tsx +188 -220
- package/template/src/components/StorageContext.tsx +5 -5
- package/template/src/components/StoreToken.tsx +5 -1
- package/template/src/components/chat-messages/useChatMessages.tsx +208 -0
- package/template/src/components/chat-notification/useChatNotification.tsx +78 -0
- package/template/src/components/chat-ui/useChatUIControl.tsx +66 -0
- package/template/src/components/common/Error.tsx +54 -0
- package/template/src/components/common/Logo.tsx +35 -0
- package/template/src/components/common/index.tsx +8 -0
- package/template/src/components/contexts/LiveStreamDataContext.tsx +79 -0
- package/template/src/components/contexts/ScreenShareContext.tsx +47 -0
- package/template/src/components/contexts/WhiteboardContext.tsx +59 -0
- package/template/src/components/dimension/DimensionContext.ts +27 -0
- package/template/src/components/dimension/DimensionProvider.tsx +34 -0
- package/template/src/components/livestream/LiveStreamContext.tsx +293 -272
- package/template/src/components/livestream/Types.ts +26 -7
- package/template/src/components/livestream/index.ts +13 -2
- package/template/src/components/livestream/views/LiveStreamControls.tsx +5 -1
- package/template/src/components/meeting-info/useMeetingInfo.tsx +63 -0
- package/template/src/components/meeting-info/useSetMeetingInfo.tsx +38 -0
- package/template/src/components/participants/AllAudienceParticipants.tsx +26 -21
- package/template/src/components/participants/AllHostParticipants.tsx +41 -53
- package/template/src/components/participants/MeParticipant.tsx +9 -10
- package/template/src/components/participants/ParticipantName.tsx +2 -1
- package/template/src/components/participants/RemoteParticipants.tsx +3 -3
- package/template/src/components/precall/LocalMute.native.tsx +91 -0
- package/template/src/components/precall/LocalMute.tsx +90 -0
- package/template/src/components/precall/VideoPreview.native.tsx +35 -0
- package/template/src/components/precall/VideoPreview.tsx +33 -0
- package/template/src/components/precall/index.tsx +28 -0
- package/template/src/components/precall/joinCallBtn.native.tsx +69 -0
- package/template/src/components/precall/joinCallBtn.tsx +91 -0
- package/template/src/components/precall/meetingTitle.tsx +26 -0
- package/template/src/components/precall/selectDevice.tsx +46 -0
- package/template/src/components/precall/textInput.tsx +43 -0
- package/template/src/components/precall/usePreCall.tsx +41 -0
- package/template/src/components/styles.ts +20 -3
- package/template/src/components/useShareLink.tsx +239 -0
- package/template/src/components/useWakeLock.tsx +3 -3
- package/template/src/custom-events/CustomEvents.ts +221 -0
- package/template/src/custom-events/index.tsx +4 -0
- package/template/src/custom-events/types.ts +51 -0
- package/template/src/language/default-labels/commonLabels.ts +21 -0
- package/template/src/language/default-labels/createScreenLabels.ts +22 -0
- package/template/src/language/default-labels/index.ts +38 -0
- package/template/src/language/default-labels/joinScreenLabels.ts +13 -0
- package/template/src/language/default-labels/precallScreenLabels.ts +33 -0
- package/template/src/language/default-labels/shareLinkScreenLabels.ts +44 -0
- package/template/src/language/default-labels/videoCallScreenLabels.ts +189 -0
- package/template/src/language/i18nTypes.ts +10 -0
- package/template/src/language/index.ts +18 -0
- package/template/src/language/useLanguage.tsx +92 -0
- package/template/src/pages/Authenticate.tsx +21 -15
- package/template/src/pages/Create.tsx +176 -159
- package/template/src/pages/Join.tsx +44 -32
- package/template/src/pages/VideoCall.tsx +134 -406
- package/template/src/pages/create/useCreate.tsx +37 -0
- package/template/src/pages/video-call/CustomLayout.ts +17 -0
- package/template/src/pages/video-call/CustomUserContextHolder.tsx +12 -0
- package/template/src/pages/video-call/DefaultLayouts.ts +65 -0
- package/template/src/pages/video-call/NameWithMicStatus.tsx +62 -0
- package/template/src/pages/video-call/RenderComponent.tsx +52 -0
- package/template/src/pages/video-call/VideoCallScreen.tsx +191 -0
- package/template/src/pages/video-call/VideoComponent.tsx +34 -0
- package/template/src/pages/video-call/VideoRenderer.tsx +86 -0
- package/template/src/pages/video-call/index.ts +20 -0
- package/template/src/rtm/RTMEngine.ts +58 -0
- package/template/src/rtm/utils.ts +44 -0
- package/template/src/rtm-events/EventUtils.ts +267 -0
- package/template/src/rtm-events/EventsQueue.ts +38 -0
- package/template/src/rtm-events/constants.ts +40 -0
- package/template/src/rtm-events/index.tsx +8 -0
- package/template/src/rtm-events/types.ts +7 -0
- package/template/src/subComponents/ChatBubble.tsx +18 -11
- package/template/src/subComponents/ChatContainer.tsx +79 -30
- package/template/src/subComponents/ChatInput.tsx +146 -70
- package/template/src/subComponents/CopyJoinInfo.tsx +52 -67
- package/template/src/subComponents/Error.tsx +35 -24
- package/template/src/subComponents/LanguageSelector.tsx +85 -0
- package/template/src/subComponents/LayoutIconDropdown.native.tsx +163 -0
- package/template/src/subComponents/LayoutIconDropdown.tsx +198 -0
- package/template/src/subComponents/LocalAudioMute.tsx +52 -30
- package/template/src/subComponents/LocalEndCall.tsx +52 -0
- package/template/src/subComponents/LocalSwitchCamera.tsx +61 -0
- package/template/src/subComponents/LocalVideoMute.tsx +48 -30
- package/template/src/subComponents/LogoutButton.tsx +20 -5
- package/template/src/subComponents/NetworkQualityPill.tsx +43 -13
- package/template/src/subComponents/OpenInNativeButton.tsx +3 -2
- package/template/src/subComponents/Recording.tsx +46 -138
- package/template/src/subComponents/RemoteAudioMute.tsx +30 -34
- package/template/src/subComponents/RemoteEndCall.tsx +18 -7
- package/template/src/subComponents/RemoteVideoMute.tsx +17 -9
- package/template/src/subComponents/ScreenShareNotice.tsx +40 -40
- package/template/src/subComponents/SelectDevice.tsx +88 -45
- package/template/src/subComponents/SelectOAuth.tsx +30 -6
- package/template/src/subComponents/SidePanelButtons.ts +39 -0
- package/template/src/subComponents/TextWithTooltip.native.tsx +2 -1
- package/template/src/subComponents/TextWithTooltip.tsx +15 -20
- package/template/src/subComponents/chat/ChatParticipants.tsx +31 -32
- package/template/src/subComponents/livestream/ApprovedLiveStreamControlsView.tsx +7 -3
- package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +32 -18
- package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +22 -8
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +12 -7
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +24 -27
- package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +23 -26
- package/template/src/subComponents/livestream/index.ts +10 -2
- package/template/src/subComponents/recording/useRecording.tsx +209 -0
- package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +64 -0
- package/template/src/subComponents/screenshare/ScreenshareButton.native.tsx +18 -0
- package/template/src/subComponents/screenshare/ScreenshareButton.tsx +61 -31
- package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +57 -52
- package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +102 -143
- package/template/src/subComponents/screenshare/useScreenshare.tsx +29 -0
- package/template/src/subComponents/toastConfig.tsx +25 -20
- package/template/src/utils/IsAttendeeUser.ts +34 -0
- package/template/src/utils/SdkEvents.ts +68 -0
- package/template/src/utils/common.tsx +40 -0
- package/template/src/utils/eventEmitter.ts +29 -0
- package/template/src/utils/getMeetingInvite.ts +30 -0
- package/template/src/utils/index.tsx +11 -2
- package/template/src/utils/isAudioEnabled.ts +29 -0
- package/template/src/utils/isHostUser.ts +33 -0
- package/template/src/utils/isMobileOrTablet.native.ts +5 -0
- package/template/src/utils/{mobileWebTest.tsx → isMobileOrTablet.ts} +5 -2
- package/template/src/utils/isPSTNUser.ts +30 -0
- package/template/src/utils/isSDK.sdk.ts +5 -0
- package/template/src/utils/isSDK.ts +5 -0
- package/template/src/utils/isScreenShareUser.ts +31 -0
- package/template/src/utils/isVideoEnabled.ts +29 -0
- package/template/src/utils/useButtonTemplate.tsx +43 -0
- package/template/src/utils/useCreateMeeting.ts +74 -0
- package/template/src/utils/useGetLiveStreamingRequests.ts +24 -0
- package/template/src/utils/useGetMeetingPhrase.ts +68 -0
- package/template/src/utils/useGetName.ts +20 -0
- package/template/src/{subComponents/screenshare/ScreenshareContext.tsx → utils/useGroupMessages.ts} +10 -7
- package/template/src/utils/useJoinMeeting.ts +120 -0
- package/template/src/utils/useLayout.tsx +40 -0
- package/template/src/utils/useLiveStreamingUids.ts +26 -0
- package/template/src/utils/useMutePSTN.ts +43 -0
- package/template/src/utils/useMuteToggleLocal.ts +109 -0
- package/template/src/utils/useNavParams.ts +6 -0
- package/template/src/utils/useNavigateTo.ts +8 -0
- package/template/src/utils/usePrivateMessages.ts +33 -0
- package/template/src/utils/useRemoteEndCall.ts +27 -0
- package/template/src/utils/useRemoteMute.ts +64 -0
- package/template/src/utils/useSendControlMessage.ts +51 -0
- package/template/src/utils/useSendMessage.ts +40 -0
- package/template/src/utils/useSetName.ts +20 -0
- package/template/src/utils/useSetUnreadMessageCount.ts +43 -0
- package/template/src/utils/useSidePanel.tsx +41 -0
- package/template/src/utils/useString.ts +61 -0
- package/template/src/utils/useUnreadMessageCount.ts +50 -0
- package/template/src/utils/useUserList.ts +26 -0
- package/template/tsconfig.json +4 -4
- package/template/tsconfig_fpeApi.json +103 -0
- package/template/tsconfig_rsdk_index.json +105 -0
- package/template/tsconfig_wsdk_index.json +104 -0
- package/template/webpack.commons.js +40 -16
- package/template/webpack.main.config.js +2 -1
- package/template/webpack.renderer.config.js +1 -1
- package/template/webpack.rsdk.config.js +33 -0
- package/template/webpack.ts.config.js +89 -0
- package/template/webpack.web.config.js +8 -1
- package/template/webpack.wsdk.config.js +34 -0
- package/template/agora-rn-uikit/.git/HEAD +0 -1
- package/template/agora-rn-uikit/.git/config +0 -16
- package/template/agora-rn-uikit/.git/description +0 -1
- package/template/agora-rn-uikit/.git/hooks/applypatch-msg.sample +0 -15
- package/template/agora-rn-uikit/.git/hooks/commit-msg.sample +0 -24
- package/template/agora-rn-uikit/.git/hooks/fsmonitor-watchman.sample +0 -173
- package/template/agora-rn-uikit/.git/hooks/post-update.sample +0 -8
- package/template/agora-rn-uikit/.git/hooks/pre-applypatch.sample +0 -14
- package/template/agora-rn-uikit/.git/hooks/pre-commit.sample +0 -49
- package/template/agora-rn-uikit/.git/hooks/pre-merge-commit.sample +0 -13
- package/template/agora-rn-uikit/.git/hooks/pre-push.sample +0 -53
- package/template/agora-rn-uikit/.git/hooks/pre-rebase.sample +0 -169
- package/template/agora-rn-uikit/.git/hooks/pre-receive.sample +0 -24
- package/template/agora-rn-uikit/.git/hooks/prepare-commit-msg.sample +0 -42
- package/template/agora-rn-uikit/.git/hooks/push-to-checkout.sample +0 -78
- package/template/agora-rn-uikit/.git/hooks/update.sample +0 -128
- package/template/agora-rn-uikit/.git/index +0 -0
- package/template/agora-rn-uikit/.git/info/exclude +0 -6
- package/template/agora-rn-uikit/.git/logs/HEAD +0 -2
- package/template/agora-rn-uikit/.git/logs/refs/heads/ab-dev-auto +0 -1
- package/template/agora-rn-uikit/.git/logs/refs/heads/master +0 -1
- package/template/agora-rn-uikit/.git/logs/refs/remotes/origin/HEAD +0 -1
- package/template/agora-rn-uikit/.git/objects/pack/pack-0061d00cd98162a329a32b537488a35d0abeb069.idx +0 -0
- package/template/agora-rn-uikit/.git/objects/pack/pack-0061d00cd98162a329a32b537488a35d0abeb069.pack +0 -0
- package/template/agora-rn-uikit/.git/packed-refs +0 -24
- package/template/agora-rn-uikit/.git/refs/heads/ab-dev-auto +0 -1
- package/template/agora-rn-uikit/.git/refs/heads/master +0 -1
- package/template/agora-rn-uikit/.git/refs/remotes/origin/HEAD +0 -1
- package/template/agora-rn-uikit/.gitignore +0 -63
- package/template/agora-rn-uikit/package-lock.json +0 -7612
- package/template/agora-rn-uikit/src/Contexts/MaxUidContext.tsx +0 -7
- package/template/agora-rn-uikit/src/Contexts/MinUidContext.tsx +0 -8
- package/template/package-lock.json +0 -22923
- package/template/react-native-toast-message/.gitignore +0 -5
- package/template/react-native-toast-message/.npmignore +0 -5
- package/template/react-native-toast-message/package-lock.json +0 -10553
- package/template/src/.DS_Store +0 -0
- package/template/src/components/participants/context/ParticipantContext.tsx +0 -97
- package/template/src/subComponents/.DS_Store +0 -0
- package/template/src/subComponents/ScreenshareButton.tsx +0 -257
- package/template/src/subComponents/SwitchCamera.tsx +0 -35
- package/template/src/utils/hasBrandLogo.tsx +0 -3
- package/template/src/utils/mobileWebTest.native.tsx +0 -5
- package/template/src/utils/shouldAuthenticate.tsx +0 -7
|
@@ -0,0 +1,109 @@
|
|
|
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 {useContext} from 'react';
|
|
13
|
+
import {RtcContext, LocalContext} from '../../agora-rn-uikit';
|
|
14
|
+
import {ToggleState} from '../../agora-rn-uikit/src/Contexts/PropsContext';
|
|
15
|
+
|
|
16
|
+
export enum MUTE_LOCAL_TYPE {
|
|
17
|
+
audio,
|
|
18
|
+
video,
|
|
19
|
+
}
|
|
20
|
+
function useMuteToggleLocal() {
|
|
21
|
+
const {RtcEngine, dispatch} = useContext(RtcContext);
|
|
22
|
+
const local = useContext(LocalContext);
|
|
23
|
+
|
|
24
|
+
return async (type: MUTE_LOCAL_TYPE) => {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case MUTE_LOCAL_TYPE.audio:
|
|
27
|
+
let localAudioState = local.audio;
|
|
28
|
+
// Don't do anything if it is in a transitional state
|
|
29
|
+
if (
|
|
30
|
+
localAudioState === ToggleState.enabled ||
|
|
31
|
+
localAudioState === ToggleState.disabled
|
|
32
|
+
) {
|
|
33
|
+
// Disable UI
|
|
34
|
+
dispatch({
|
|
35
|
+
type: 'LocalMuteAudio',
|
|
36
|
+
value: [
|
|
37
|
+
localAudioState === ToggleState.enabled
|
|
38
|
+
? ToggleState.disabling
|
|
39
|
+
: ToggleState.enabling,
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await RtcEngine.muteLocalAudioStream(
|
|
45
|
+
localAudioState === ToggleState.enabled,
|
|
46
|
+
);
|
|
47
|
+
// Enable UI
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'LocalMuteAudio',
|
|
50
|
+
value: [
|
|
51
|
+
localAudioState === ToggleState.enabled
|
|
52
|
+
? ToggleState.disabled
|
|
53
|
+
: ToggleState.enabled,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
dispatch({
|
|
59
|
+
type: 'LocalMuteAudio',
|
|
60
|
+
value: [localAudioState],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case MUTE_LOCAL_TYPE.video:
|
|
66
|
+
const localVideoState = local.video;
|
|
67
|
+
// Don't do anything if it is in a transitional state
|
|
68
|
+
if (
|
|
69
|
+
localVideoState === ToggleState.enabled ||
|
|
70
|
+
localVideoState === ToggleState.disabled
|
|
71
|
+
) {
|
|
72
|
+
// Disable UI
|
|
73
|
+
dispatch({
|
|
74
|
+
type: 'LocalMuteVideo',
|
|
75
|
+
value: [
|
|
76
|
+
localVideoState === ToggleState.enabled
|
|
77
|
+
? ToggleState.disabling
|
|
78
|
+
: ToggleState.enabling,
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await RtcEngine.muteLocalVideoStream(
|
|
84
|
+
localVideoState === ToggleState.enabled ? true : false,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Enable UI
|
|
88
|
+
dispatch({
|
|
89
|
+
type: 'LocalMuteVideo',
|
|
90
|
+
value: [
|
|
91
|
+
localVideoState === ToggleState.enabled
|
|
92
|
+
? ToggleState.disabled
|
|
93
|
+
: ToggleState.enabled,
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.log('error while dispatching');
|
|
98
|
+
dispatch({
|
|
99
|
+
type: 'LocalMuteVideo',
|
|
100
|
+
value: [localVideoState],
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default useMuteToggleLocal;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 {useChatMessages} from '../components/chat-messages/useChatMessages';
|
|
14
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This hook will return function to find the private message by uid
|
|
18
|
+
* @returns private message
|
|
19
|
+
*/
|
|
20
|
+
function usePrivateMessages() {
|
|
21
|
+
const {privateMessageStore} = useChatMessages();
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param uid - User id
|
|
25
|
+
* @returns If uid is passed then it will return particular private message data
|
|
26
|
+
* otherwise it will return whole private message store
|
|
27
|
+
*/
|
|
28
|
+
const getPrivateMessage = (uid?: UidType) =>
|
|
29
|
+
uid ? privateMessageStore[uid] : privateMessageStore;
|
|
30
|
+
return getPrivateMessage;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default usePrivateMessages;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {controlMessageEnum} from '../components/ChatContext';
|
|
2
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
3
|
+
import {useMeetingInfo} from '../components/meeting-info/useMeetingInfo';
|
|
4
|
+
import useIsPSTN from './isPSTNUser';
|
|
5
|
+
import useSendControlMessage, {
|
|
6
|
+
CONTROL_MESSAGE_TYPE,
|
|
7
|
+
} from '../utils/useSendControlMessage';
|
|
8
|
+
|
|
9
|
+
const useRemoteEndCall = () => {
|
|
10
|
+
const sendCtrlMsgToUid = useSendControlMessage();
|
|
11
|
+
const {isHost} = useMeetingInfo();
|
|
12
|
+
const isPSTN = useIsPSTN();
|
|
13
|
+
return (uid: UidType) => {
|
|
14
|
+
if (isHost) {
|
|
15
|
+
if (!isPSTN(uid)) {
|
|
16
|
+
sendCtrlMsgToUid(
|
|
17
|
+
CONTROL_MESSAGE_TYPE.controlMessageToUid,
|
|
18
|
+
controlMessageEnum.kickUser,
|
|
19
|
+
uid,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
console.error('A host can only remove the audience from the call.');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default useRemoteEndCall;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 {useMeetingInfo} from '../components/meeting-info/useMeetingInfo';
|
|
13
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
14
|
+
import {controlMessageEnum} from '../components/ChatContext';
|
|
15
|
+
import useIsPSTN from './isPSTNUser';
|
|
16
|
+
import useMutePSTN from './useMutePSTN';
|
|
17
|
+
import useSendControlMessage, {
|
|
18
|
+
CONTROL_MESSAGE_TYPE,
|
|
19
|
+
} from '../utils/useSendControlMessage';
|
|
20
|
+
|
|
21
|
+
export enum MUTE_REMOTE_TYPE {
|
|
22
|
+
audio,
|
|
23
|
+
video,
|
|
24
|
+
}
|
|
25
|
+
function useRemoteMute() {
|
|
26
|
+
const sendCtrlMsgToUid = useSendControlMessage();
|
|
27
|
+
const {isHost} = useMeetingInfo();
|
|
28
|
+
const isPSTN = useIsPSTN();
|
|
29
|
+
const mutePSTN = useMutePSTN();
|
|
30
|
+
return async (type: MUTE_REMOTE_TYPE, uid: UidType) => {
|
|
31
|
+
if (isHost) {
|
|
32
|
+
switch (type) {
|
|
33
|
+
case MUTE_REMOTE_TYPE.audio:
|
|
34
|
+
if (isPSTN(uid)) {
|
|
35
|
+
try {
|
|
36
|
+
mutePSTN(uid);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('An error occurred while muting the PSTN user.');
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
sendCtrlMsgToUid(
|
|
42
|
+
CONTROL_MESSAGE_TYPE.controlMessageToUid,
|
|
43
|
+
controlMessageEnum.muteAudio,
|
|
44
|
+
uid,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
case MUTE_REMOTE_TYPE.video:
|
|
49
|
+
if (!isPSTN(uid)) {
|
|
50
|
+
sendCtrlMsgToUid(
|
|
51
|
+
CONTROL_MESSAGE_TYPE.controlMessageToUid,
|
|
52
|
+
controlMessageEnum.muteVideo,
|
|
53
|
+
uid,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.error('A host can only mute audience audio or video.');
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default useRemoteMute;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 {UidType} from '../../agora-rn-uikit';
|
|
13
|
+
import {useContext} from 'react';
|
|
14
|
+
import ChatContext, {controlMessageEnum} from '../components/ChatContext';
|
|
15
|
+
import {LiveStreamControlMessageEnum} from '../components/livestream';
|
|
16
|
+
import {useMeetingInfo} from '../components/meeting-info/useMeetingInfo';
|
|
17
|
+
|
|
18
|
+
export enum CONTROL_MESSAGE_TYPE {
|
|
19
|
+
controlMessageToEveryOne,
|
|
20
|
+
controlMessageToUid,
|
|
21
|
+
}
|
|
22
|
+
function useSendControlMessage() {
|
|
23
|
+
const {sendControlMessage, sendControlMessageToUid} = useContext(ChatContext);
|
|
24
|
+
const {isHost} = useMeetingInfo();
|
|
25
|
+
return (
|
|
26
|
+
type: CONTROL_MESSAGE_TYPE,
|
|
27
|
+
message: controlMessageEnum | LiveStreamControlMessageEnum,
|
|
28
|
+
uid?: UidType,
|
|
29
|
+
) => {
|
|
30
|
+
if (isHost || ($config.EVENT_MODE && $config.RAISE_HAND)) {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case CONTROL_MESSAGE_TYPE.controlMessageToEveryOne:
|
|
33
|
+
sendControlMessage(message);
|
|
34
|
+
break;
|
|
35
|
+
case CONTROL_MESSAGE_TYPE.controlMessageToUid:
|
|
36
|
+
if (uid) {
|
|
37
|
+
sendControlMessageToUid(message, uid);
|
|
38
|
+
} else {
|
|
39
|
+
console.error('UID should be passed');
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
console.error('A host can only send the control message.');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default useSendControlMessage;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 {useContext} from 'react';
|
|
13
|
+
import ChatContext from '../components/ChatContext';
|
|
14
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
15
|
+
|
|
16
|
+
export enum MESSAGE_TYPE {
|
|
17
|
+
group,
|
|
18
|
+
private,
|
|
19
|
+
}
|
|
20
|
+
function useSendMessage() {
|
|
21
|
+
const {sendMessage, sendMessageToUid} = useContext(ChatContext);
|
|
22
|
+
return (type: MESSAGE_TYPE, message: string, uid?: UidType) => {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case MESSAGE_TYPE.group:
|
|
25
|
+
sendMessage(message);
|
|
26
|
+
break;
|
|
27
|
+
case MESSAGE_TYPE.private:
|
|
28
|
+
if (uid) {
|
|
29
|
+
sendMessageToUid(message, uid);
|
|
30
|
+
} else {
|
|
31
|
+
console.error('To send the private message, UID should be passed');
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default useSendMessage;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 {useContext} from 'react';
|
|
13
|
+
import ChatContext from '../components/ChatContext';
|
|
14
|
+
|
|
15
|
+
function useSetName() {
|
|
16
|
+
const {setDisplayName} = useContext(ChatContext);
|
|
17
|
+
return setDisplayName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default useSetName;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {UidType} from '../../agora-rn-uikit';
|
|
2
|
+
import {useChatNotification} from '../components/chat-notification/useChatNotification';
|
|
3
|
+
|
|
4
|
+
export enum SET_UNREAD_MESSAGE_COUNT_TYPE {
|
|
5
|
+
setPublicMessageCount,
|
|
6
|
+
setIndividualMessageCount,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const useSetUnreadMessageCount = () => {
|
|
10
|
+
const {setUnreadIndividualMessageCount, setUnreadGroupMessageCount} =
|
|
11
|
+
useChatNotification();
|
|
12
|
+
return (
|
|
13
|
+
type: SET_UNREAD_MESSAGE_COUNT_TYPE,
|
|
14
|
+
count: number,
|
|
15
|
+
uid?: UidType,
|
|
16
|
+
) => {
|
|
17
|
+
switch (type) {
|
|
18
|
+
case SET_UNREAD_MESSAGE_COUNT_TYPE.setPublicMessageCount:
|
|
19
|
+
setUnreadGroupMessageCount(count);
|
|
20
|
+
break;
|
|
21
|
+
case SET_UNREAD_MESSAGE_COUNT_TYPE.setIndividualMessageCount:
|
|
22
|
+
if (uid) {
|
|
23
|
+
setUnreadIndividualMessageCount((prevState) => {
|
|
24
|
+
if (prevState && prevState.hasOwnProperty(uid)) {
|
|
25
|
+
return {
|
|
26
|
+
...prevState,
|
|
27
|
+
[uid]: count,
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
console.error(`ERROR: Invalid UID`);
|
|
31
|
+
return prevState;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
console.error('UID must be passed for setIndividualMessageCount.');
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export default useSetUnreadMessageCount;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 React, {SetStateAction} from 'react';
|
|
14
|
+
import {SidePanelType} from '../subComponents/SidePanelEnum';
|
|
15
|
+
import {createHook} from 'fpe-implementation';
|
|
16
|
+
|
|
17
|
+
export interface SidePanelContextInterface {
|
|
18
|
+
sidePanel: SidePanelType;
|
|
19
|
+
setSidePanel: React.Dispatch<SetStateAction<SidePanelType>>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SidePanelContext = React.createContext<SidePanelContextInterface>({
|
|
23
|
+
sidePanel: SidePanelType.None,
|
|
24
|
+
setSidePanel: () => {},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
interface SidePanelProviderProps {
|
|
28
|
+
value: SidePanelContextInterface;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
const SidePanelProvider = (props: SidePanelProviderProps) => {
|
|
32
|
+
return (
|
|
33
|
+
<SidePanelContext.Provider value={{...props.value}}>
|
|
34
|
+
{props.children}
|
|
35
|
+
</SidePanelContext.Provider>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const useSidePanel = createHook(SidePanelContext);
|
|
40
|
+
|
|
41
|
+
export {SidePanelProvider, useSidePanel};
|
|
@@ -0,0 +1,61 @@
|
|
|
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 {useFpe} from 'fpe-api';
|
|
13
|
+
import {useLanguage} from '../language/useLanguage';
|
|
14
|
+
import {DEFAULT_I18_DATA} from '../language';
|
|
15
|
+
import {TextDataInterface} from '../language/default-labels/index';
|
|
16
|
+
|
|
17
|
+
export function usei18nData(
|
|
18
|
+
selectedLanguageCode: string = DEFAULT_I18_DATA.locale,
|
|
19
|
+
) {
|
|
20
|
+
const languageData = useFpe((data) => data?.i18n);
|
|
21
|
+
if (
|
|
22
|
+
!selectedLanguageCode ||
|
|
23
|
+
!languageData ||
|
|
24
|
+
(languageData && !Array.isArray(languageData)) ||
|
|
25
|
+
(languageData && Array.isArray(languageData) && !languageData.length)
|
|
26
|
+
) {
|
|
27
|
+
return DEFAULT_I18_DATA.data;
|
|
28
|
+
} else {
|
|
29
|
+
let selectedLanguageData = languageData.find(
|
|
30
|
+
(item) => item.locale === selectedLanguageCode,
|
|
31
|
+
);
|
|
32
|
+
if (selectedLanguageData && selectedLanguageData.data) {
|
|
33
|
+
return {
|
|
34
|
+
...DEFAULT_I18_DATA.data,
|
|
35
|
+
...selectedLanguageData.data,
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
return DEFAULT_I18_DATA.data;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function useString<T = string>(
|
|
44
|
+
keyName: keyof TextDataInterface,
|
|
45
|
+
): (input?: T) => string {
|
|
46
|
+
const lanCode = useLanguage((data) => data.languageCode);
|
|
47
|
+
const textData = usei18nData(lanCode);
|
|
48
|
+
const getString = (input?: T) => {
|
|
49
|
+
let keyValue = textData ? textData[keyName] : undefined;
|
|
50
|
+
if (!keyValue) {
|
|
51
|
+
return '';
|
|
52
|
+
} else if (typeof keyValue === 'function') {
|
|
53
|
+
return keyValue(input);
|
|
54
|
+
} else if (typeof keyValue === 'string') {
|
|
55
|
+
return keyValue;
|
|
56
|
+
} else {
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return getString;
|
|
61
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 {UidType} from '../../agora-rn-uikit';
|
|
13
|
+
import {useChatNotification} from '../components/chat-notification/useChatNotification';
|
|
14
|
+
|
|
15
|
+
export enum UNREAD_MESSAGE_COUNT_TYPE {
|
|
16
|
+
GroupAndPrivateCount,
|
|
17
|
+
GroupCount,
|
|
18
|
+
PrivateCount,
|
|
19
|
+
PaticularUserUnReadCount,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function useUnreadMessageCount() {
|
|
23
|
+
const {
|
|
24
|
+
totalUnreadCount,
|
|
25
|
+
unreadGroupMessageCount,
|
|
26
|
+
unreadPrivateMessageCount,
|
|
27
|
+
unreadIndividualMessageCount,
|
|
28
|
+
} = useChatNotification();
|
|
29
|
+
|
|
30
|
+
const getUnreadCount = (type: UNREAD_MESSAGE_COUNT_TYPE, uid?: UidType) => {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case UNREAD_MESSAGE_COUNT_TYPE.GroupAndPrivateCount:
|
|
33
|
+
return totalUnreadCount;
|
|
34
|
+
case UNREAD_MESSAGE_COUNT_TYPE.GroupCount:
|
|
35
|
+
return unreadGroupMessageCount;
|
|
36
|
+
case UNREAD_MESSAGE_COUNT_TYPE.PrivateCount:
|
|
37
|
+
return unreadPrivateMessageCount;
|
|
38
|
+
case UNREAD_MESSAGE_COUNT_TYPE.PaticularUserUnReadCount:
|
|
39
|
+
return uid && unreadIndividualMessageCount[uid]
|
|
40
|
+
? unreadIndividualMessageCount[uid]
|
|
41
|
+
: 0;
|
|
42
|
+
default:
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return getUnreadCount;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default useUnreadMessageCount;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 {useRenderContext} from 'fpe-api';
|
|
13
|
+
/**
|
|
14
|
+
* This hook will fetch the user list
|
|
15
|
+
* @returns userList
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function useUserList() {
|
|
19
|
+
const {renderPosition, renderList} = useRenderContext();
|
|
20
|
+
return {
|
|
21
|
+
renderList: renderList,
|
|
22
|
+
renderPosition: renderPosition,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default useUserList;
|
package/template/tsconfig.json
CHANGED
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
11
|
// "checkJs": true, /* Report errors in .js files. */
|
|
12
12
|
"jsx": "react-native", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
14
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
15
15
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
16
16
|
// "outDir": "./", /* Redirect output structure to the directory. */
|
|
17
17
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
18
18
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
19
|
-
"noEmit":
|
|
19
|
+
"noEmit": false, /* Do not emit outputs. */
|
|
20
20
|
// "incremental": true, /* Enable incremental compilation */
|
|
21
21
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
22
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
23
23
|
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
24
|
|
|
25
25
|
/* Strict Type-Checking Options */
|
|
26
|
-
"strict":
|
|
27
|
-
|
|
26
|
+
"strict": false, /* Enable all strict type-checking options. */
|
|
27
|
+
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
28
28
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
29
29
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
30
30
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|