agora-appbuilder-core 2.3.0-beta.2 → 2.3.0-beta.22

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.
Files changed (78) hide show
  1. package/Readme.md +11 -6
  2. package/package.json +2 -2
  3. package/template/Gulpfile.js +112 -13
  4. package/template/_package-lock.json +13011 -13288
  5. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +2 -0
  6. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +4 -5
  7. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +3 -1
  8. package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +3 -1
  9. package/template/agora-rn-uikit/src/Rtc/Create.tsx +64 -33
  10. package/template/agora-rn-uikit/src/Rtc/Join.tsx +11 -2
  11. package/template/agora-rn-uikit/src/RtcConfigure.tsx +23 -4
  12. package/template/agora-rn-uikit/src/Utils/permission.ts +17 -6
  13. package/template/bridge/rtc/webNg/RtcEngine.ts +51 -26
  14. package/template/esbuild.rsdk.go +20 -6
  15. package/template/fpe-api/components.ts +15 -0
  16. package/template/fpe-api/context.ts +2 -3
  17. package/template/fpe-api/install.ts +19 -9
  18. package/template/fpe-api/typeDefinition.ts +7 -6
  19. package/template/fpe-api/utils.ts +32 -25
  20. package/template/global.d.ts +3 -2
  21. package/template/index.rsdk.tsx +15 -4
  22. package/template/index.wsdk.tsx +13 -3
  23. package/template/package.json +4 -2
  24. package/template/react-native-toast-message/src/index.js +3 -7
  25. package/template/react-native-toast-message/src/{index.wsdk.js → index.sdk.tsx} +1 -1
  26. package/template/react-native-toast-message/src/styles.sdk.ts +17 -0
  27. package/template/src/SDKAppWrapper.tsx +1 -1
  28. package/template/src/components/Chat.tsx +23 -5
  29. package/template/src/components/ChatContext.ts +15 -4
  30. package/template/src/components/Controls.native.tsx +10 -6
  31. package/template/src/components/Controls.tsx +6 -4
  32. package/template/src/components/HostControlView.tsx +5 -3
  33. package/template/src/components/Navbar.tsx +15 -13
  34. package/template/src/components/RTMConfigure.tsx +20 -50
  35. package/template/src/components/chat-messages/useChatMessages.tsx +369 -70
  36. package/template/src/components/contexts/LiveStreamDataContext.tsx +3 -3
  37. package/template/src/components/contexts/ScreenShareContext.tsx +2 -0
  38. package/template/src/components/livestream/LiveStreamContext.tsx +9 -6
  39. package/template/src/components/participants/MeParticipant.tsx +5 -3
  40. package/template/src/components/participants/RemoteParticipants.tsx +9 -7
  41. package/template/src/components/precall/LocalMute.native.tsx +12 -8
  42. package/template/src/components/precall/LocalMute.tsx +5 -3
  43. package/template/src/components/precall/textInput.tsx +1 -1
  44. package/template/src/components/useShareLink.tsx +37 -39
  45. package/template/src/components/useUserPreference.tsx +125 -0
  46. package/template/src/custom-events/CustomEvents.ts +39 -23
  47. package/template/src/custom-events/types.ts +3 -3
  48. package/template/src/language/default-labels/videoCallScreenLabels.ts +4 -2
  49. package/template/src/pages/Create.tsx +10 -3
  50. package/template/src/pages/Join.tsx +4 -1
  51. package/template/src/pages/VideoCall.tsx +61 -56
  52. package/template/src/pages/video-call/CustomUserContextHolder.tsx +13 -5
  53. package/template/src/pages/video-call/VideoCallScreen.tsx +18 -15
  54. package/template/src/rtm/RTMEngine.ts +13 -0
  55. package/template/src/rtm/utils.ts +1 -1
  56. package/template/src/rtm-events/EventUtils.ts +3 -0
  57. package/template/src/rtm-events/EventsQueue.ts +9 -3
  58. package/template/src/rtm-events/constants.ts +3 -1
  59. package/template/src/subComponents/ChatBubble.tsx +22 -4
  60. package/template/src/subComponents/ChatContainer.tsx +30 -19
  61. package/template/src/subComponents/ChatInput.tsx +38 -26
  62. package/template/src/subComponents/SelectDevice.tsx +1 -1
  63. package/template/src/subComponents/recording/useRecording.tsx +15 -4
  64. package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +11 -5
  65. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +35 -26
  66. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +83 -33
  67. package/template/src/utils/SdkEvents.ts +3 -3
  68. package/template/src/utils/getMeetingInvite.ts +38 -15
  69. package/template/src/utils/getUniqueID.ts +5 -0
  70. package/template/src/utils/useDeleteMessage.ts +36 -0
  71. package/template/src/utils/useEditMessage.ts +41 -0
  72. package/template/src/utils/useGetName.ts +2 -3
  73. package/template/src/utils/useJoinMeeting.ts +22 -14
  74. package/template/src/utils/useLocalShareScreenUid.ts +19 -0
  75. package/template/src/utils/useSendMessage.ts +4 -5
  76. package/template/src/utils/useSetName.ts +2 -4
  77. package/template/webpack.rsdk.config.js +3 -2
  78. package/template/webpack.wsdk.config.js +0 -1
@@ -20,15 +20,7 @@ import useUserList from '../../utils/useUserList';
20
20
  import {useScreenContext} from '../../components/contexts/ScreenShareContext';
21
21
  import {useString} from '../../utils/useString';
22
22
  import CustomEvents from '../../custom-events';
23
- import {EventNames} from '../../rtm-events';
24
-
25
- function usePrevious(value: any) {
26
- const ref = useRef();
27
- useEffect(() => {
28
- ref.current = value;
29
- });
30
- return ref.current;
31
- }
23
+ import {EventNames, EventActions} from '../../rtm-events';
32
24
 
33
25
  export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
34
26
  const rtc = useContext(RtcContext);
@@ -40,7 +32,6 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
40
32
  // const userText = useString('remoteUserDefaultLabel')();
41
33
  const getScreenShareName = (name: string) => `${name}'s screenshare`;
42
34
  const userText = 'User';
43
- const prevRenderPosition = usePrevious({renderPosition});
44
35
  const setPinnedLayout = useSetPinnedLayout();
45
36
  const changeLayout = useChangeDefaultLayout();
46
37
 
@@ -58,9 +49,8 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
58
49
  value: [screenShareUid],
59
50
  });
60
51
  setPinnedLayout();
61
- }
62
- //screenshare is stopped set the layout Grid View
63
- else {
52
+ } else {
53
+ //screenshare is stopped set the layout Grid View
64
54
  changeLayout();
65
55
  }
66
56
  };
@@ -69,19 +59,38 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
69
59
  CustomEvents.on(EventNames.SCREENSHARE_ATTRIBUTE, (data) => {
70
60
  const screenUidOfUser =
71
61
  renderListRef.current.renderList[data.sender].screenUid;
72
- setScreenShareData((prevState) => {
73
- return {
74
- ...prevState,
75
- [screenUidOfUser]: {
76
- name: renderListRef.current.renderList[screenUidOfUser]?.name,
77
- isActive: data.payload.value === 'true' ? true : false,
78
- },
79
- };
80
- });
81
- //if remote user started/stopped the screenshare then change the layout to pinned/grid
82
- data.payload.value === 'true'
83
- ? triggerChangeLayout(true, screenUidOfUser)
84
- : triggerChangeLayout(false);
62
+ switch (data?.payload?.action) {
63
+ case EventActions.SCREENSHARE_STARTED:
64
+ setScreenShareData((prevState) => {
65
+ return {
66
+ ...prevState,
67
+ [screenUidOfUser]: {
68
+ name: renderListRef.current.renderList[screenUidOfUser]?.name,
69
+ isActive: true,
70
+ ts: data.payload.value || 0,
71
+ },
72
+ };
73
+ });
74
+ //if remote user started/stopped the screenshare then change the layout to pinned/grid
75
+ triggerChangeLayout(true, screenUidOfUser);
76
+ break;
77
+ case EventActions.SCREENSHARE_STOPPED:
78
+ setScreenShareData((prevState) => {
79
+ return {
80
+ ...prevState,
81
+ [screenUidOfUser]: {
82
+ name: renderListRef.current.renderList[screenUidOfUser]?.name,
83
+ isActive: false,
84
+ ts: data.payload.value || 0,
85
+ },
86
+ };
87
+ });
88
+ //if remote user started/stopped the screenshare then change the layout to pinned/grid
89
+ triggerChangeLayout(false);
90
+ break;
91
+ default:
92
+ break;
93
+ }
85
94
  });
86
95
  }, []);
87
96
 
@@ -1,3 +1,14 @@
1
+ /*
2
+ ********************************************
3
+ Copyright © 2022 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
+ */
1
12
  import React, {useContext, useEffect, useRef, useState} from 'react';
2
13
  import {RtcContext, PropsContext, UidType} from '../../../agora-rn-uikit';
3
14
  import {ScreenshareContext} from './useScreenshare';
@@ -9,18 +20,11 @@ import {useRecording} from '../recording/useRecording';
9
20
  import {useScreenContext} from '../../components/contexts/ScreenShareContext';
10
21
  import useUserList from '../../utils/useUserList';
11
22
  import CustomEvents, {EventLevel} from '../../custom-events';
12
- import {EventNames} from '../../rtm-events';
23
+ import {EventActions, EventNames} from '../../rtm-events';
13
24
  import {IAgoraRTC} from 'agora-rtc-sdk-ng';
14
25
  import useRecordingLayoutQuery from '../recording/useRecordingLayoutQuery';
15
26
  import {useString} from '../../utils/useString';
16
-
17
- function usePrevious<T = any>(value: any) {
18
- const ref = useRef<T>();
19
- useEffect(() => {
20
- ref.current = value;
21
- });
22
- return ref.current;
23
- }
27
+ import {timeNow} from '../../rtm/utils';
24
28
 
25
29
  export const ScreenshareContextConsumer = ScreenshareContext.Consumer;
26
30
 
@@ -67,19 +71,38 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
67
71
  CustomEvents.on(EventNames.SCREENSHARE_ATTRIBUTE, (data) => {
68
72
  const screenUidOfUser =
69
73
  renderListRef.current.renderList[data.sender].screenUid;
70
- setScreenShareData((prevState) => {
71
- return {
72
- ...prevState,
73
- [screenUidOfUser]: {
74
- name: renderListRef.current.renderList[screenUidOfUser]?.name,
75
- isActive: data.payload.value === 'true' ? true : false,
76
- },
77
- };
78
- });
79
- //if remote user started/stopped the screenshare then change the layout to pinned/grid
80
- data.payload.value === 'true'
81
- ? triggerChangeLayout(true, screenUidOfUser)
82
- : triggerChangeLayout(false);
74
+ switch (data?.payload?.action) {
75
+ case EventActions.SCREENSHARE_STARTED:
76
+ setScreenShareData((prevState) => {
77
+ return {
78
+ ...prevState,
79
+ [screenUidOfUser]: {
80
+ name: renderListRef.current.renderList[screenUidOfUser]?.name,
81
+ isActive: true,
82
+ ts: data.payload.value || 0,
83
+ },
84
+ };
85
+ });
86
+ //if remote user started/stopped the screenshare then change the layout to pinned/grid
87
+ triggerChangeLayout(true, screenUidOfUser);
88
+ break;
89
+ case EventActions.SCREENSHARE_STOPPED:
90
+ setScreenShareData((prevState) => {
91
+ return {
92
+ ...prevState,
93
+ [screenUidOfUser]: {
94
+ name: renderListRef.current.renderList[screenUidOfUser]?.name,
95
+ isActive: false,
96
+ ts: data.payload.value || 0,
97
+ },
98
+ };
99
+ });
100
+ //if remote user started/stopped the screenshare then change the layout to pinned/grid
101
+ triggerChangeLayout(false);
102
+ break;
103
+ default:
104
+ break;
105
+ }
83
106
  });
84
107
  }, []);
85
108
 
@@ -90,18 +113,30 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
90
113
  console.log('STOPPED SHARING');
91
114
  executeNormalQuery();
92
115
  CustomEvents.send(EventNames.SCREENSHARE_ATTRIBUTE, {
93
- value: `${false}`,
116
+ action: EventActions.SCREENSHARE_STOPPED,
117
+ value: 0,
94
118
  level: EventLevel.LEVEL2,
95
119
  });
120
+ setScreenShareData((prevState) => {
121
+ return {
122
+ ...prevState,
123
+ [screenShareUid]: {
124
+ ...prevState[screenShareUid],
125
+ isActive: false,
126
+ ts: 0,
127
+ },
128
+ };
129
+ });
96
130
  //if local user stopped the screenshare then change layout to grid
97
131
  triggerChangeLayout(false);
98
132
  });
99
133
  }, []);
100
134
 
101
135
  const executeRecordingQuery = (isScreenActive: boolean) => {
102
- if (!isScreenActive) {
136
+ if (isScreenActive) {
137
+ console.log('screenshare: Executing presenter query');
103
138
  // If screen share is not going on, start the screen share by executing the graphql query
104
- executePresenterQuery();
139
+ executePresenterQuery(screenShareUid);
105
140
  } else {
106
141
  // If recording is already going on, stop the recording by executing the graphql query.
107
142
  executeNormalQuery();
@@ -121,6 +156,7 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
121
156
  if (isRecordingActive) {
122
157
  executeRecordingQuery(isActive);
123
158
  }
159
+ console.log('supriya screenshare query executed');
124
160
  try {
125
161
  // @ts-ignore
126
162
  await rtc.RtcEngine.startScreenshare(
@@ -133,18 +169,32 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
133
169
  encryption as unknown as any,
134
170
  );
135
171
  isActive && setScreenshareActive(true);
172
+
173
+ if (isActive) {
174
+ // 1. Set local state
175
+ setScreenShareData((prevState) => {
176
+ return {
177
+ ...prevState,
178
+ [screenShareUid]: {
179
+ name: renderListRef.current.renderList[screenShareUid]?.name,
180
+ isActive: true,
181
+ ts: timeNow(),
182
+ },
183
+ };
184
+ });
185
+ // 2. Inform everyone in the channel screenshare is actice
186
+ CustomEvents.send(EventNames.SCREENSHARE_ATTRIBUTE, {
187
+ action: EventActions.SCREENSHARE_STARTED,
188
+ value: timeNow(),
189
+ level: EventLevel.LEVEL2,
190
+ });
191
+ //3 . if local user started the screenshare then change layout to pinned
192
+ triggerChangeLayout(true, screenShareUid);
193
+ }
136
194
  } catch (e) {
137
195
  console.error("can't start the screen share", e);
138
196
  executeNormalQuery();
139
197
  }
140
- if (isActive) {
141
- CustomEvents.send(EventNames.SCREENSHARE_ATTRIBUTE, {
142
- value: `${true}`,
143
- level: EventLevel.LEVEL2,
144
- });
145
- //if local user started the screenshare then change layout to pinned
146
- triggerChangeLayout(true, screenShareUid);
147
- }
148
198
  };
149
199
 
150
200
  return (
@@ -46,7 +46,7 @@ const SDKEvents: SDKEventsInterface = {
46
46
  },
47
47
  on: function (eventName, cb) {
48
48
  console.log(
49
- 'DEBUG(aditya)-SDKEvents: event registered:',
49
+ 'SDKEvents: event registered:',
50
50
  eventName,
51
51
  );
52
52
  this.eventsMap[eventName] = cb;
@@ -55,12 +55,12 @@ const SDKEvents: SDKEventsInterface = {
55
55
  }
56
56
  },
57
57
  emit: function (eventName, ...args) {
58
- console.log('DEBUG(aditya)-SDKEvents: emit called:', eventName, ...args);
58
+ console.log('SDKEvents: emit called:', eventName, ...args);
59
59
  this.eventsMap[eventName](...args);
60
60
  this.eventSubs[eventName] = args;
61
61
  },
62
62
  off: function (eventName) {
63
- console.log('DEBUG(aditya)-SDKEvents: event deregistered:', eventName);
63
+ console.log('SDKEvents: event deregistered:', eventName);
64
64
  this.eventSubs[eventName] = null;
65
65
  },
66
66
  };
@@ -1,28 +1,51 @@
1
1
  const GetMeetingInviteURL = (
2
2
  baseUrl: string,
3
- attendee: string,
4
- host?: string,
3
+ isHost: boolean,
4
+ meetingPassphrase: {
5
+ host?: string;
6
+ attendee?: string;
7
+ },
8
+ isSeparateHostLink: boolean,
5
9
  ) => {
6
- if (host) {
7
- return {
8
- host: `${baseUrl}/${host}`,
9
- attendee: `${baseUrl}/${attendee}`,
10
- };
10
+ if (isHost) {
11
+ if (isSeparateHostLink) {
12
+ return {
13
+ host: `${baseUrl}/${meetingPassphrase.host}`,
14
+ attendee: `${baseUrl}/${meetingPassphrase.attendee}`,
15
+ };
16
+ } else {
17
+ return {
18
+ host: `${baseUrl}/${meetingPassphrase.host}`,
19
+ };
20
+ }
11
21
  } else {
12
22
  return {
13
- attendee: `${baseUrl}/${attendee}`,
23
+ attendee: `${baseUrl}/${meetingPassphrase.attendee}`,
14
24
  };
15
25
  }
16
26
  };
17
- const GetMeetingInviteID = (attendee: string, host?: string) => {
18
- if (host) {
19
- return {
20
- host: `${host}`,
21
- attendee: `${attendee}`,
22
- };
27
+ const GetMeetingInviteID = (
28
+ isHost: boolean,
29
+ meetingPassphrase: {
30
+ host?: string;
31
+ attendee?: string;
32
+ },
33
+ isSeparateHostLink: boolean,
34
+ ) => {
35
+ if (isHost) {
36
+ if (isSeparateHostLink) {
37
+ return {
38
+ host: `${meetingPassphrase.host}`,
39
+ attendee: `${meetingPassphrase.attendee}`,
40
+ };
41
+ } else {
42
+ return {
43
+ host: `${meetingPassphrase.host}`,
44
+ };
45
+ }
23
46
  } else {
24
47
  return {
25
- attendee: `${attendee}`,
48
+ attendee: `${meetingPassphrase.attendee}`,
26
49
  };
27
50
  }
28
51
  };
@@ -0,0 +1,5 @@
1
+ import {nanoid} from 'nanoid/non-secure';
2
+
3
+ export default function getUniqueID() {
4
+ return nanoid();
5
+ }
@@ -0,0 +1,36 @@
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 {useChatMessages} from '../components/chat-messages/useChatMessages';
14
+ import {MESSAGE_TYPE} from './useSendMessage';
15
+
16
+ function useDeleteMessage() {
17
+ const {deleteChatMessage} = useChatMessages();
18
+ return (type: MESSAGE_TYPE, msgId: string, uid?: UidType) => {
19
+ switch (type) {
20
+ case MESSAGE_TYPE.group:
21
+ deleteChatMessage(msgId);
22
+ break;
23
+ case MESSAGE_TYPE.private:
24
+ if (uid) {
25
+ deleteChatMessage(msgId, uid);
26
+ } else {
27
+ console.error('To delete the private message, UID should be passed');
28
+ }
29
+ break;
30
+ default:
31
+ break;
32
+ }
33
+ };
34
+ }
35
+
36
+ export default useDeleteMessage;
@@ -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
+ import {UidType} from '../../agora-rn-uikit';
13
+ import {useChatMessages} from '../components/chat-messages/useChatMessages';
14
+ import {MESSAGE_TYPE} from './useSendMessage';
15
+
16
+ function useEditMessage() {
17
+ const {editChatMessage} = useChatMessages();
18
+ return (
19
+ type: MESSAGE_TYPE,
20
+ msgId: string,
21
+ message: string,
22
+ uid?: UidType,
23
+ ) => {
24
+ switch (type) {
25
+ case MESSAGE_TYPE.group:
26
+ editChatMessage(msgId, message);
27
+ break;
28
+ case MESSAGE_TYPE.private:
29
+ if (uid) {
30
+ editChatMessage(msgId, message, uid);
31
+ } else {
32
+ console.error('To edit the private message, UID should be passed');
33
+ }
34
+ break;
35
+ default:
36
+ break;
37
+ }
38
+ };
39
+ }
40
+
41
+ export default useEditMessage;
@@ -9,11 +9,10 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import {useContext} from 'react';
13
- import ChatContext from '../components/ChatContext';
12
+ import {useUserPreference} from '../components/useUserPreference';
14
13
 
15
14
  function useGetName() {
16
- const {displayName} = useContext(ChatContext);
15
+ const {displayName} = useUserPreference();
17
16
  return displayName;
18
17
  }
19
18
 
@@ -56,19 +56,25 @@ export default function useJoinMeeting() {
56
56
  const {setMeetingInfo} = useSetMeetingInfo();
57
57
  const {client} = useContext(GraphQLContext);
58
58
  return async (phrase: string) => {
59
- const response = await client.query({
60
- query:
61
- store.token === null
62
- ? JOIN_CHANNEL_PHRASE
63
- : JOIN_CHANNEL_PHRASE_AND_GET_USER,
64
- variables: {
65
- passphrase: phrase,
66
- },
59
+ setMeetingInfo((prevState) => {
60
+ return {
61
+ ...prevState,
62
+ isJoinDataFetched: false,
63
+ };
67
64
  });
68
- if (response.error) {
69
- throw response.error;
70
- } else {
71
- try {
65
+ try {
66
+ const response = await client.query({
67
+ query:
68
+ store.token === null
69
+ ? JOIN_CHANNEL_PHRASE
70
+ : JOIN_CHANNEL_PHRASE_AND_GET_USER,
71
+ variables: {
72
+ passphrase: phrase,
73
+ },
74
+ });
75
+ if (response.error) {
76
+ throw response.error;
77
+ } else {
72
78
  if (response && response.data) {
73
79
  let data = response.data;
74
80
  let meetingInfo: Partial<MeetingInfoContextInterface> = {
@@ -111,10 +117,12 @@ export default function useJoinMeeting() {
111
117
  ...meetingInfo,
112
118
  };
113
119
  });
120
+ } else {
121
+ throw new Error('An error occurred in parsing the channel data.');
114
122
  }
115
- } catch (error) {
116
- throw new Error('An error occurred in parsing the channel data.');
117
123
  }
124
+ } catch (error) {
125
+ throw error;
118
126
  }
119
127
  };
120
128
  }
@@ -0,0 +1,19 @@
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 {PropsContext} from '../../agora-rn-uikit';
14
+
15
+ const useLocalScreenShareUid = () => {
16
+ const {rtcProps} = useContext(PropsContext);
17
+ return rtcProps?.screenShareUid || 0;
18
+ };
19
+ export default useLocalScreenShareUid;
@@ -9,24 +9,23 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import {useContext} from 'react';
13
- import ChatContext from '../components/ChatContext';
14
12
  import {UidType} from '../../agora-rn-uikit';
13
+ import {useChatMessages} from '../components/chat-messages/useChatMessages';
15
14
 
16
15
  export enum MESSAGE_TYPE {
17
16
  group,
18
17
  private,
19
18
  }
20
19
  function useSendMessage() {
21
- const {sendMessage, sendMessageToUid} = useContext(ChatContext);
20
+ const {sendChatMessage} = useChatMessages();
22
21
  return (type: MESSAGE_TYPE, message: string, uid?: UidType) => {
23
22
  switch (type) {
24
23
  case MESSAGE_TYPE.group:
25
- sendMessage(message);
24
+ sendChatMessage(message);
26
25
  break;
27
26
  case MESSAGE_TYPE.private:
28
27
  if (uid) {
29
- sendMessageToUid(message, uid);
28
+ sendChatMessage(message, uid);
30
29
  } else {
31
30
  console.error('To send the private message, UID should be passed');
32
31
  }
@@ -9,11 +9,9 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import {useContext} from 'react';
13
- import ChatContext from '../components/ChatContext';
14
-
12
+ import {useUserPreference} from '../components/useUserPreference';
15
13
  function useSetName() {
16
- const {setDisplayName} = useContext(ChatContext);
14
+ const {setDisplayName} = useUserPreference();
17
15
  return setDisplayName;
18
16
  }
19
17
 
@@ -16,6 +16,7 @@ module.exports = merge(commons, {
16
16
  'react-router': 'react-router',
17
17
  'react-router-dom': 'react-router-dom',
18
18
  '@apollo/client': '@apollo/client',
19
+ nanoid: 'nanoid',
19
20
  },
20
21
  // Main entry point for the web application
21
22
  entry: {
@@ -25,9 +26,9 @@ module.exports = merge(commons, {
25
26
  output: {
26
27
  path: path.resolve(__dirname, `../Builds/react-sdk`),
27
28
  filename: 'index.js',
28
- library:{
29
+ library: {
29
30
  type: 'commonjs2',
30
- }
31
+ },
31
32
  },
32
33
  // watch: isDevelopment
33
34
  });
@@ -20,7 +20,6 @@ const baseConfig = {
20
20
  name: 'AgoraAppBuilder',
21
21
  },
22
22
  },
23
- watch: isDevelopment
24
23
  };
25
24
 
26
25
  const mappedConfigs = libraryTargets.map((target, _) => {