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
@@ -21,39 +21,66 @@ import {useChatNotification} from '../chat-notification/useChatNotification';
21
21
  import Toast from '../../../react-native-toast-message';
22
22
  import {timeNow} from '../../rtm/utils';
23
23
  import {useSidePanel} from '../../utils/useSidePanel';
24
+ import getUniqueID from '../../utils/getUniqueID';
25
+
26
+ enum ChatMessageActionEnum {
27
+ Create = 'Create_Chat_Message',
28
+ Update = 'Update_Chat_Message',
29
+ Delete = 'Delete_Chat_Message',
30
+ }
24
31
 
25
32
  interface ChatMessagesProviderProps {
26
33
  children: React.ReactNode;
27
34
  }
28
- interface messageInterface {
29
- ts: number;
35
+ export interface messageInterface {
36
+ createdTimestamp: number;
37
+ updatedTimestamp?: number;
30
38
  msg: string;
39
+ msgId: string;
40
+ isDeleted: boolean;
31
41
  }
32
- interface messageStoreInterface extends messageInterface {
42
+ export interface messageStoreInterface extends messageInterface {
33
43
  uid: UidType;
34
44
  }
35
45
 
36
46
  interface ChatMessagesInterface {
37
- messageStore: messageStoreInterface | any;
38
- privateMessageStore: any;
47
+ messageStore: messageStoreInterface[];
48
+ privateMessageStore: {[key: string]: messageStoreInterface[]};
39
49
  sendChatMessage: (msg: string, toUid?: UidType) => void;
50
+ editChatMessage: (msgId: string, msg: string, toUid?: UidType) => void;
51
+ deleteChatMessage: (msgId: string, toUid?: UidType) => void;
40
52
  }
41
53
 
42
54
  const ChatMessagesContext = React.createContext<ChatMessagesInterface>({
43
55
  messageStore: [],
44
56
  privateMessageStore: {},
45
57
  sendChatMessage: () => {},
58
+ editChatMessage: () => {},
59
+ deleteChatMessage: () => {},
46
60
  });
47
61
 
48
62
  const ChatMessagesProvider = (props: ChatMessagesProviderProps) => {
49
63
  const {renderList} = useRenderContext();
50
64
  const localUid = useLocalUid();
51
65
  const {setSidePanel} = useSidePanel();
52
- const {groupActive, selectedChatUserId, setGroupActive} = useChatUIControl();
53
- const {setUnreadGroupMessageCount, setUnreadIndividualMessageCount} =
54
- useChatNotification();
66
+ const {
67
+ groupActive,
68
+ selectedChatUserId,
69
+ setGroupActive,
70
+ setPrivateActive,
71
+ setSelectedChatUserId,
72
+ } = useChatUIControl();
73
+ const {
74
+ setUnreadGroupMessageCount,
75
+ setUnreadIndividualMessageCount,
76
+ unreadPrivateMessageCount,
77
+ unreadIndividualMessageCount,
78
+ setUnreadPrivateMessageCount,
79
+ } = useChatNotification();
55
80
  const [messageStore, setMessageStore] = useState<messageStoreInterface[]>([]);
56
- const [privateMessageStore, setPrivateMessageStore] = useState({});
81
+ const [privateMessageStore, setPrivateMessageStore] = useState<{
82
+ [key: string]: messageStoreInterface[];
83
+ }>({});
57
84
 
58
85
  const renderListRef = useRef({renderList: renderList});
59
86
  const groupActiveRef = useRef<boolean>();
@@ -75,70 +102,207 @@ const ChatMessagesProvider = (props: ChatMessagesProviderProps) => {
75
102
  }, [selectedChatUserId]);
76
103
 
77
104
  React.useEffect(() => {
78
- const showMessageNotification = (msg: string, uid: string) => {
105
+ const showMessageNotification = (
106
+ msg: string,
107
+ uid: string,
108
+ isPrivateMessage: boolean = false,
109
+ ) => {
110
+ const uidAsNumber = parseInt(uid);
79
111
  Toast.show({
80
112
  type: 'success',
81
113
  text1: msg.length > 30 ? msg.slice(0, 30) + '...' : msg,
82
- text2: renderListRef.current.renderList[parseInt(uid)]?.name
83
- ? fromText(renderListRef.current.renderList[parseInt(uid)]?.name)
114
+ text2: renderListRef.current.renderList[uidAsNumber]?.name
115
+ ? fromText(renderListRef.current.renderList[uidAsNumber]?.name)
84
116
  : '',
85
117
  visibilityTime: 1000,
86
118
  onPress: () => {
119
+ if (isPrivateMessage) {
120
+ setUnreadPrivateMessageCount(
121
+ unreadPrivateMessageCount -
122
+ (unreadIndividualMessageCount[uidAsNumber] || 0),
123
+ );
124
+ setUnreadIndividualMessageCount((prevState) => {
125
+ return {
126
+ ...prevState,
127
+ [uidAsNumber]: 0,
128
+ };
129
+ });
130
+ setGroupActive(false);
131
+ setSelectedChatUserId(uidAsNumber);
132
+ setPrivateActive(true);
133
+ } else {
134
+ setUnreadGroupMessageCount(0);
135
+ setPrivateActive(false);
136
+ setSelectedChatUserId(0);
137
+ setGroupActive(true);
138
+ }
87
139
  setSidePanel(SidePanelType.Chat);
88
- setUnreadGroupMessageCount(0);
89
- setGroupActive(true);
90
140
  },
91
141
  });
92
142
  };
93
143
  CustomEvents.on(EventNames.PUBLIC_CHAT_MESSAGE, (data) => {
94
- showMessageNotification(data.payload.value, data.sender);
95
- addMessageToStore(parseInt(data.sender), {
96
- msg: data.payload.value,
97
- ts: data.ts,
98
- });
99
- /**
100
- * if chat group window is not active.
101
- * then we will increment the unread count
102
- */
103
- if (!groupActiveRef.current) {
104
- setUnreadGroupMessageCount((prevState) => {
105
- return prevState + 1;
106
- });
144
+ const messageData = JSON.parse(data.payload.value);
145
+ switch (data?.payload?.action) {
146
+ case ChatMessageActionEnum.Create:
147
+ showMessageNotification(messageData.msg, data.sender);
148
+ addMessageToStore(parseInt(data.sender), {
149
+ msg: messageData.msg,
150
+ createdTimestamp: messageData.createdTimestamp,
151
+ isDeleted: messageData.isDeleted,
152
+ msgId: messageData.msgId,
153
+ });
154
+ /**
155
+ * if chat group window is not active.
156
+ * then we will increment the unread count
157
+ */
158
+ if (!groupActiveRef.current) {
159
+ setUnreadGroupMessageCount((prevState) => {
160
+ return prevState + 1;
161
+ });
162
+ }
163
+ break;
164
+ case ChatMessageActionEnum.Update:
165
+ setMessageStore((prevState) => {
166
+ const newState = prevState.map((item) => {
167
+ if (
168
+ item.msgId === messageData.msgId &&
169
+ item.uid === parseInt(data.sender)
170
+ ) {
171
+ return {
172
+ ...item,
173
+ msg: messageData.msg,
174
+ updatedTimestamp: messageData.updatedTimestamp,
175
+ };
176
+ } else {
177
+ return item;
178
+ }
179
+ });
180
+ return newState;
181
+ });
182
+ break;
183
+ case ChatMessageActionEnum.Delete:
184
+ setMessageStore((prevState) => {
185
+ const newState = prevState.map((item) => {
186
+ if (
187
+ item.msgId === messageData.msgId &&
188
+ item.uid === parseInt(data.sender)
189
+ ) {
190
+ return {
191
+ ...item,
192
+ isDeleted: true,
193
+ updatedTimestamp: messageData.updatedTimestamp,
194
+ };
195
+ } else {
196
+ return item;
197
+ }
198
+ });
199
+ return newState;
200
+ });
201
+ break;
202
+ default:
203
+ break;
107
204
  }
108
205
  });
109
206
  CustomEvents.on(EventNames.PRIVATE_CHAT_MESSAGE, (data) => {
110
- showMessageNotification(data.payload.value, data.sender);
111
- addMessageToPrivateStore(
112
- parseInt(data.sender),
113
- {
114
- msg: data.payload.value,
115
- ts: data.ts,
116
- },
117
- false,
118
- );
119
- /**
120
- * if user's private window is active.
121
- * then we will not increment the unread count
122
- */
123
-
124
- if (!(individualActiveRef.current === parseInt(data.sender))) {
125
- setUnreadIndividualMessageCount((prevState) => {
126
- const prevCount =
127
- prevState && prevState[parseInt(data.sender)]
128
- ? prevState[parseInt(data.sender)]
129
- : 0;
130
- return {
131
- ...prevState,
132
- [parseInt(data.sender)]: prevCount + 1,
133
- };
134
- });
207
+ const messageData = JSON.parse(data.payload.value);
208
+
209
+ switch (data?.payload?.action) {
210
+ case ChatMessageActionEnum.Create:
211
+ showMessageNotification(messageData.msg, data.sender, true);
212
+ addMessageToPrivateStore(
213
+ parseInt(data.sender),
214
+ {
215
+ msg: messageData.msg,
216
+ createdTimestamp: messageData.createdTimestamp,
217
+ msgId: messageData.msgId,
218
+ isDeleted: messageData.isDeleted,
219
+ },
220
+ false,
221
+ );
222
+ /**
223
+ * if user's private window is active.
224
+ * then we will not increment the unread count
225
+ */
226
+
227
+ if (!(individualActiveRef.current === parseInt(data.sender))) {
228
+ setUnreadIndividualMessageCount((prevState) => {
229
+ const prevCount =
230
+ prevState && prevState[parseInt(data.sender)]
231
+ ? prevState[parseInt(data.sender)]
232
+ : 0;
233
+ return {
234
+ ...prevState,
235
+ [parseInt(data.sender)]: prevCount + 1,
236
+ };
237
+ });
238
+ }
239
+ break;
240
+ case ChatMessageActionEnum.Update:
241
+ setPrivateMessageStore((prevState) => {
242
+ const privateChatOfUid = prevState[parseInt(data.sender)];
243
+ const updatedData = privateChatOfUid.map((item) => {
244
+ if (
245
+ item.msgId === messageData.msgId &&
246
+ item.uid === parseInt(data.sender)
247
+ ) {
248
+ return {
249
+ ...item,
250
+ msg: messageData.msg,
251
+ updatedTimestamp: messageData.updatedTimestamp,
252
+ };
253
+ } else {
254
+ return item;
255
+ }
256
+ });
257
+ const newState = {
258
+ ...prevState,
259
+ [parseInt(data.sender)]: updatedData,
260
+ };
261
+ return newState;
262
+ });
263
+ break;
264
+ case ChatMessageActionEnum.Delete:
265
+ setPrivateMessageStore((prevState) => {
266
+ const privateChatOfUid = prevState[parseInt(data.sender)];
267
+ const updatedData = privateChatOfUid.map((item) => {
268
+ if (
269
+ item.msgId === messageData.msgId &&
270
+ item.uid === parseInt(data.sender)
271
+ ) {
272
+ return {
273
+ ...item,
274
+ isDeleted: true,
275
+ updatedTimestamp: messageData.updatedTimestamp,
276
+ };
277
+ } else {
278
+ return item;
279
+ }
280
+ });
281
+ const newState = {
282
+ ...prevState,
283
+ [parseInt(data.sender)]: updatedData,
284
+ };
285
+ return newState;
286
+ });
287
+ break;
288
+ default:
289
+ break;
135
290
  }
136
291
  });
137
292
  }, []);
138
293
 
139
294
  const addMessageToStore = (uid: UidType, body: messageInterface) => {
140
295
  setMessageStore((m: messageStoreInterface[]) => {
141
- return [...m, {ts: body.ts, uid, msg: body.msg}];
296
+ return [
297
+ ...m,
298
+ {
299
+ createdTimestamp: body.createdTimestamp,
300
+ uid,
301
+ msg: body.msg,
302
+ msgId: body.msgId,
303
+ isDeleted: body.isDeleted,
304
+ },
305
+ ];
142
306
  });
143
307
  };
144
308
 
@@ -147,16 +311,30 @@ const ChatMessagesProvider = (props: ChatMessagesProviderProps) => {
147
311
  body: messageInterface,
148
312
  local: boolean,
149
313
  ) => {
150
- setPrivateMessageStore((state: any) => {
314
+ setPrivateMessageStore((state) => {
151
315
  let newState = {...state};
152
316
  newState[uid] !== undefined
153
317
  ? (newState[uid] = [
154
318
  ...newState[uid],
155
- {ts: body.ts, uid: local ? localUid : uid, msg: body.msg},
319
+ {
320
+ createdTimestamp: body.createdTimestamp,
321
+ uid: local ? localUid : uid,
322
+ msg: body.msg,
323
+ msgId: body.msgId,
324
+ isDeleted: body.isDeleted,
325
+ },
156
326
  ])
157
327
  : (newState = {
158
328
  ...newState,
159
- [uid]: [{ts: body.ts, uid: local ? localUid : uid, msg: body.msg}],
329
+ [uid]: [
330
+ {
331
+ createdTimestamp: body.createdTimestamp,
332
+ uid: local ? localUid : uid,
333
+ msg: body.msg,
334
+ msgId: body.msgId,
335
+ isDeleted: body.isDeleted,
336
+ },
337
+ ],
160
338
  });
161
339
  return {...newState};
162
340
  });
@@ -165,29 +343,148 @@ const ChatMessagesProvider = (props: ChatMessagesProviderProps) => {
165
343
  const sendChatMessage = (msg: string, toUid?: UidType) => {
166
344
  if (typeof msg == 'string' && msg.trim() === '') return;
167
345
  if (toUid) {
346
+ const messageData = {
347
+ msg,
348
+ createdTimestamp: timeNow(),
349
+ msgId: getUniqueID(),
350
+ isDeleted: false,
351
+ };
168
352
  CustomEvents.send(
169
353
  EventNames.PRIVATE_CHAT_MESSAGE,
170
354
  {
171
- value: msg,
355
+ value: JSON.stringify(messageData),
356
+ action: ChatMessageActionEnum.Create,
172
357
  },
173
358
  toUid,
174
359
  );
175
- addMessageToPrivateStore(
176
- toUid,
177
- {
178
- msg: msg,
179
- ts: timeNow(),
180
- },
181
- true,
182
- );
360
+ addMessageToPrivateStore(toUid, messageData, true);
183
361
  } else {
362
+ const messageData = {
363
+ msg,
364
+ msgId: getUniqueID(),
365
+ isDeleted: false,
366
+ createdTimestamp: timeNow(),
367
+ };
184
368
  CustomEvents.send(EventNames.PUBLIC_CHAT_MESSAGE, {
185
- value: msg,
186
- });
187
- addMessageToStore(localUid, {
188
- msg: msg,
189
- ts: timeNow(),
369
+ value: JSON.stringify(messageData),
370
+ action: ChatMessageActionEnum.Create,
190
371
  });
372
+ addMessageToStore(localUid, messageData);
373
+ }
374
+ };
375
+
376
+ const editChatMessage = (msgId: string, msg: string, toUid?: UidType) => {
377
+ if (typeof msg == 'string' && msg.trim() === '') return;
378
+ if (toUid) {
379
+ const checkData = privateMessageStore[toUid].filter(
380
+ (item) => item.msgId === msgId && item.uid === localUid,
381
+ );
382
+ if (checkData && checkData.length) {
383
+ const editMsgData = {msg, updatedTimestamp: timeNow()};
384
+ CustomEvents.send(
385
+ EventNames.PRIVATE_CHAT_MESSAGE,
386
+ {
387
+ value: JSON.stringify({msgId, ...editMsgData}),
388
+ action: ChatMessageActionEnum.Update,
389
+ },
390
+ toUid,
391
+ );
392
+ setPrivateMessageStore((prevState) => {
393
+ const privateChatOfUid = prevState[toUid];
394
+ const updatedData = privateChatOfUid.map((item) => {
395
+ if (item.msgId === msgId) {
396
+ return {...item, ...editMsgData};
397
+ } else {
398
+ return item;
399
+ }
400
+ });
401
+ const newState = {...prevState, [toUid]: updatedData};
402
+ return newState;
403
+ });
404
+ } else {
405
+ console.log("You don't have permission to edit");
406
+ }
407
+ } else {
408
+ //check if user has permission to edit
409
+ const checkData = messageStore.filter(
410
+ (item) => item.msgId === msgId && item.uid === localUid,
411
+ );
412
+ if (checkData && checkData.length) {
413
+ const editMsgData = {msg, updatedTimestamp: timeNow()};
414
+ CustomEvents.send(EventNames.PUBLIC_CHAT_MESSAGE, {
415
+ value: JSON.stringify({msgId, ...editMsgData}),
416
+ action: ChatMessageActionEnum.Update,
417
+ });
418
+ setMessageStore((prevState) => {
419
+ const newState = prevState.map((item) => {
420
+ if (item.msgId === msgId) {
421
+ return {...item, ...editMsgData};
422
+ } else {
423
+ return item;
424
+ }
425
+ });
426
+ return newState;
427
+ });
428
+ } else {
429
+ console.log("You don't have permission to edit");
430
+ }
431
+ }
432
+ };
433
+
434
+ const deleteChatMessage = (msgId: string, toUid?: UidType) => {
435
+ if (toUid) {
436
+ const checkData = privateMessageStore[toUid].filter(
437
+ (item) => item.msgId === msgId && item.uid === localUid,
438
+ );
439
+ if (checkData && checkData.length) {
440
+ const deleteMsgData = {updatedTimestamp: timeNow()};
441
+ CustomEvents.send(
442
+ EventNames.PRIVATE_CHAT_MESSAGE,
443
+ {
444
+ value: JSON.stringify({msgId, ...deleteMsgData}),
445
+ action: ChatMessageActionEnum.Delete,
446
+ },
447
+ toUid,
448
+ );
449
+ setPrivateMessageStore((prevState) => {
450
+ const privateChatOfUid = prevState[toUid];
451
+ const updatedData = privateChatOfUid.map((item) => {
452
+ if (item.msgId === msgId) {
453
+ return {...item, isDeleted: true, ...deleteMsgData};
454
+ } else {
455
+ return item;
456
+ }
457
+ });
458
+ const newState = {...prevState, [toUid]: updatedData};
459
+ return newState;
460
+ });
461
+ } else {
462
+ console.log("You don't have permission to delete");
463
+ }
464
+ } else {
465
+ //check if user has permission to delete
466
+ const checkData = messageStore.filter(
467
+ (item) => item.msgId === msgId && item.uid === localUid,
468
+ );
469
+ if (checkData && checkData.length) {
470
+ const deleteMsgData = {updatedTimestamp: timeNow()};
471
+ CustomEvents.send(EventNames.PUBLIC_CHAT_MESSAGE, {
472
+ value: JSON.stringify({msgId, ...deleteMsgData}),
473
+ action: ChatMessageActionEnum.Delete,
474
+ });
475
+ setMessageStore((prevState) => {
476
+ const newState = prevState.map((item) => {
477
+ if (item.msgId === msgId) {
478
+ return {...item, isDeleted: true, ...deleteMsgData};
479
+ } else {
480
+ return item;
481
+ }
482
+ });
483
+ return newState;
484
+ });
485
+ } else {
486
+ console.log("You don't have permission to delete");
487
+ }
191
488
  }
192
489
  };
193
490
 
@@ -197,6 +494,8 @@ const ChatMessagesProvider = (props: ChatMessagesProviderProps) => {
197
494
  messageStore,
198
495
  privateMessageStore,
199
496
  sendChatMessage,
497
+ editChatMessage,
498
+ deleteChatMessage,
200
499
  }}>
201
500
  {props.children}
202
501
  </ChatMessagesContext.Provider>
@@ -30,7 +30,6 @@ interface ScreenShareProviderProps {
30
30
  children: React.ReactNode;
31
31
  }
32
32
  const LiveStreamDataProvider = (props: ScreenShareProviderProps) => {
33
- const localUid = useLocalUid();
34
33
  const {renderList} = useUserList();
35
34
  const {raiseHandList} = useContext(LiveStreamContext);
36
35
  const [hostUids, setHostUids] = useState<UidType[]>([]);
@@ -41,13 +40,14 @@ const LiveStreamDataProvider = (props: ScreenShareProviderProps) => {
41
40
  const hostList = filterObject(
42
41
  renderList,
43
42
  ([k, v]) =>
44
- (v?.type === 'rtc' || v?.type === 'live') &&
43
+ (v?.type === 'rtc' ||
44
+ v?.type === 'live' ||
45
+ (v?.type === 'screenshare' && v?.video == 1)) &&
45
46
  (raiseHandList[k]
46
47
  ? raiseHandList[k]?.role == ClientRole.Broadcaster
47
48
  : true) &&
48
49
  !v?.offline,
49
50
  );
50
-
51
51
  const audienceList = filterObject(
52
52
  renderList,
53
53
  ([k, v]) =>
@@ -12,6 +12,7 @@ export interface ScreenShareObjectInterface {
12
12
  [key: string | number]: {
13
13
  name: string;
14
14
  isActive: boolean;
15
+ ts: number;
15
16
  };
16
17
  }
17
18
  export interface ScreenShareContextInterface {
@@ -33,6 +34,7 @@ const ScreenShareProvider = (props: ScreenShareProviderProps) => {
33
34
  [rtcProps?.screenShareUid]: {
34
35
  name: '',
35
36
  isActive: false,
37
+ ts: 0,
36
38
  },
37
39
  });
38
40
 
@@ -26,6 +26,8 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
26
26
  props,
27
27
  ) => {
28
28
  const screenshareContextInstance = useScreenshare();
29
+ const screenshareContextInstanceRef = useRef<any>();
30
+ screenshareContextInstanceRef.current = screenshareContextInstance;
29
31
 
30
32
  const {renderList} = useUserList();
31
33
  const renderListRef = useRef<any>();
@@ -91,7 +93,7 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
91
93
  payload: Partial<raiseHandItemInterface>,
92
94
  ) => {
93
95
  if (userUID && !isEmptyObject(payload)) {
94
- const userId = userUID.toString();
96
+ const userId = `${userUID}`;
95
97
  setRaiseHandList((oldRaisedHandList) => ({
96
98
  ...oldRaisedHandList,
97
99
  [userId]: {
@@ -187,7 +189,7 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
187
189
  ...prevState[data.sender],
188
190
  role:
189
191
  data.payload.value in ClientRole
190
- ? ClientRole[data.payload.value]
192
+ ? parseInt(data.payload.value)
191
193
  : ClientRole.Audience,
192
194
  },
193
195
  };
@@ -317,7 +319,8 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
317
319
  ) {
318
320
  /** 2.b */
319
321
  showToast(LSNotificationObject.RAISE_HAND_APPROVED_REQUEST_RECALL);
320
- screenshareContextInstance?.stopUserScreenShare(); // This will not exist on ios
322
+ screenshareContextInstanceRef?.current?.stopUserScreenShare(); // This will not exist on ios
323
+
321
324
  // Demote user's privileges to audience
322
325
  changeClientRoleTo(ClientRole.Audience);
323
326
  }
@@ -342,7 +345,7 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
342
345
  */
343
346
 
344
347
  const hostApprovesRequestOfUID = (uid: UidType) => {
345
- addOrUpdateLiveStreamRequest(uid.toString(), {
348
+ addOrUpdateLiveStreamRequest(`${uid}`, {
346
349
  raised: RaiseHandValue.TRUE,
347
350
  ts: new Date().getTime(),
348
351
  });
@@ -354,7 +357,7 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
354
357
  };
355
358
 
356
359
  const hostRejectsRequestOfUID = (uid: UidType) => {
357
- addOrUpdateLiveStreamRequest(uid.toString(), {
360
+ addOrUpdateLiveStreamRequest(`${uid}`, {
358
361
  raised: RaiseHandValue.FALSE,
359
362
  ts: new Date().getTime(),
360
363
  });
@@ -403,7 +406,7 @@ export const LiveStreamContextProvider: React.FC<liveStreamPropsInterface> = (
403
406
  raiseHandList[localUidRef.current]?.role == ClientRole.Broadcaster &&
404
407
  raiseHandList[localUidRef.current]?.raised === RaiseHandValue.TRUE
405
408
  ) {
406
- screenshareContextInstance?.stopUserScreenShare(); // This will not exist on ios
409
+ screenshareContextInstanceRef?.current?.stopUserScreenShare(); // This will not exist on ios
407
410
  // Change role
408
411
  changeClientRoleTo(ClientRole.Audience);
409
412
  }
@@ -26,9 +26,11 @@ const MeParticipant = (props: any) => {
26
26
  <View style={[p_style.actionBtnIcon, {marginRight: 10}]}>
27
27
  <LocalAudioMute buttonTemplateName={ButtonTemplateName.topBar} />
28
28
  </View>
29
- <View style={p_style.actionBtnIcon}>
30
- <LocalVideoMute buttonTemplateName={ButtonTemplateName.topBar} />
31
- </View>
29
+ {!$config.AUDIO_ROOM && (
30
+ <View style={p_style.actionBtnIcon}>
31
+ <LocalVideoMute buttonTemplateName={ButtonTemplateName.topBar} />
32
+ </View>
33
+ )}
32
34
  </View>
33
35
  </View>
34
36
  );
@@ -49,13 +49,15 @@ const RemoteParticipants = (props: remoteParticipantsInterface) => {
49
49
  isHost={isHost}
50
50
  />
51
51
  </View>
52
- <View style={[p_styles.actionBtnIcon]}>
53
- <RemoteVideoMute
54
- uid={user.uid}
55
- video={user.video}
56
- isHost={isHost}
57
- />
58
- </View>
52
+ {!$config.AUDIO_ROOM && (
53
+ <View style={[p_styles.actionBtnIcon]}>
54
+ <RemoteVideoMute
55
+ uid={user.uid}
56
+ video={user.video}
57
+ isHost={isHost}
58
+ />
59
+ </View>
60
+ )}
59
61
  </View>
60
62
  ) : (
61
63
  <></>