agora-appbuilder-core 4.0.27 → 4.0.28-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.
Files changed (83) hide show
  1. package/package.json +2 -2
  2. package/template/_package-lock.json +10 -7
  3. package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +9 -0
  4. package/template/bridge/rtm/web/index.ts +44 -26
  5. package/template/customization-api/app-state.ts +1 -0
  6. package/template/customization-api/atoms.ts +8 -0
  7. package/template/customization-api/index.ts +1 -0
  8. package/template/customization-api/sub-components.ts +4 -1
  9. package/template/customization-api/temp.ts +1 -2
  10. package/template/customization-api/typeDefinition.ts +8 -0
  11. package/template/customization-api/types.ts +3 -0
  12. package/template/customization-api/utils.ts +10 -1
  13. package/template/defaultConfig.js +2 -2
  14. package/template/ios/HelloWorld.xcodeproj/project.pbxproj +102 -50
  15. package/template/ios/HelloWorld.xcodeproj/xcshareddata/xcschemes/ScreenSharing.xcscheme +95 -0
  16. package/template/ios/Podfile +1 -1
  17. package/template/ios/Podfile.lock +200 -44
  18. package/template/ios/ScreenSharing/SampleHandler.h +2 -6
  19. package/template/ios/ScreenSharing/SampleHandler.m +17 -48
  20. package/template/package-lock.json +10 -7
  21. package/template/package.json +1 -1
  22. package/template/src/AppWrapper.tsx +2 -2
  23. package/template/src/assets/selection.json +3491 -1
  24. package/template/src/atoms/ActionMenu.tsx +96 -113
  25. package/template/src/atoms/LinkButton.tsx +4 -3
  26. package/template/src/atoms/ToolbarItem.tsx +36 -22
  27. package/template/src/atoms/ToolbarPreset.tsx +18 -3
  28. package/template/src/components/Controls.tsx +72 -49
  29. package/template/src/components/CustomSidePanel.tsx +82 -0
  30. package/template/src/components/EventsConfigure.tsx +11 -27
  31. package/template/src/components/Navbar.tsx +51 -86
  32. package/template/src/components/NavbarMobile.tsx +27 -3
  33. package/template/src/components/PinnedVideo.tsx +9 -0
  34. package/template/src/components/RTMConfigure.tsx +69 -1
  35. package/template/src/components/Settings.tsx +6 -29
  36. package/template/src/components/chat/chatConfigure.native.tsx +123 -119
  37. package/template/src/components/chat/chatConfigure.tsx +59 -46
  38. package/template/src/components/chat-messages/useChatMessages.tsx +5 -4
  39. package/template/src/components/chat-ui/useChatUIControls.tsx +4 -1
  40. package/template/src/components/livestream/views/LiveStreamControls.tsx +2 -1
  41. package/template/src/components/participants/UserActionMenuOptions.tsx +10 -10
  42. package/template/src/components/virtual-background/VBButton.tsx +5 -7
  43. package/template/src/language/default-labels/videoCallScreenLabels.ts +9 -2
  44. package/template/src/language/i18nTypes.ts +1 -1
  45. package/template/src/pages/video-call/ActionSheet.native.tsx +110 -34
  46. package/template/src/pages/video-call/ActionSheet.tsx +109 -27
  47. package/template/src/pages/video-call/ActionSheetContent.tsx +67 -49
  48. package/template/src/pages/video-call/ActionSheetHandle.tsx +12 -2
  49. package/template/src/pages/video-call/SidePanelHeader.tsx +28 -2
  50. package/template/src/pages/video-call/VideoCallScreen.tsx +70 -16
  51. package/template/src/pages/video-call/VideoRenderer.tsx +1 -0
  52. package/template/src/rtm-events-api/Events.ts +37 -3
  53. package/template/src/rtm-events-api/LocalEvents.ts +1 -0
  54. package/template/src/rtm-events-api/types.ts +5 -0
  55. package/template/src/subComponents/ChatBubble.tsx +15 -1
  56. package/template/src/subComponents/ChatInput.tsx +18 -7
  57. package/template/src/subComponents/CopyJoinInfo.tsx +5 -13
  58. package/template/src/subComponents/LayoutIconButton.tsx +6 -14
  59. package/template/src/subComponents/LocalAudioMute.tsx +7 -11
  60. package/template/src/subComponents/LocalEndCall.tsx +6 -4
  61. package/template/src/subComponents/LocalSwitchCamera.tsx +5 -4
  62. package/template/src/subComponents/LocalVideoMute.tsx +10 -36
  63. package/template/src/subComponents/Recording.tsx +4 -10
  64. package/template/src/subComponents/ScreenShareNotice.tsx +3 -0
  65. package/template/src/subComponents/SidePanelEnum.tsx +6 -6
  66. package/template/src/subComponents/caption/CaptionContainer.tsx +2 -2
  67. package/template/src/subComponents/caption/CaptionIcon.tsx +21 -17
  68. package/template/src/subComponents/caption/TranscriptIcon.tsx +6 -3
  69. package/template/src/subComponents/chat/ChatActionMenu.tsx +3 -3
  70. package/template/src/subComponents/chat/ChatAttachment.tsx +107 -51
  71. package/template/src/subComponents/chat/ChatEmoji.tsx +8 -4
  72. package/template/src/subComponents/chat/ChatSendButton.tsx +52 -30
  73. package/template/src/subComponents/chat/ChatUploadStatus.tsx +22 -3
  74. package/template/src/subComponents/chat/ImagePopup.tsx +4 -4
  75. package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +14 -25
  76. package/template/src/subComponents/screenshare/ScreenshareButton.tsx +8 -7
  77. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +333 -163
  78. package/template/src/utils/common.tsx +22 -9
  79. package/template/src/utils/useEndCall.ts +6 -4
  80. package/template/src/utils/useFullScreen.native.ts +12 -0
  81. package/template/src/utils/useOrientation.tsx +46 -46
  82. package/template/src/utils/useSidePanel.tsx +2 -2
  83. package/template/src/utils/useString.ts +6 -4
@@ -9,7 +9,7 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import React, {useContext, useEffect, useState} from 'react';
12
+ import React, {useContext, useEffect} from 'react';
13
13
  import {
14
14
  View,
15
15
  Text,
@@ -21,50 +21,37 @@ import Settings, {
21
21
  SettingsWithViewWrapper,
22
22
  SettingsIconButtonProps,
23
23
  } from './Settings';
24
- import CopyJoinInfo, {CopyJoinInfoProps} from '../subComponents/CopyJoinInfo';
25
24
  import {SidePanelType} from '../subComponents/SidePanelEnum';
26
25
  import ChatContext from '../components/ChatContext';
27
26
  import isMobileOrTablet from '../utils/isMobileOrTablet';
28
27
  import LiveStreamContext from './livestream';
29
28
  import {filterObject, numFormatter} from '../utils/index';
30
- import {useLayout} from '../utils/useLayout';
31
29
  import {useChatNotification} from '../components/chat-notification/useChatNotification';
32
- import useLayoutsData from '../pages/video-call/useLayoutsData';
33
30
  import {
34
31
  BREAKPOINTS,
35
32
  CustomToolbarMerge,
36
- CustomToolbarSort,
37
33
  CustomToolbarSorting,
38
- isAndroid,
39
34
  isIOS,
40
- isMobileUA,
41
- isValidReactComponent,
42
35
  isWebInternal,
43
36
  trimText,
44
- updateToolbarDefaultConfig,
45
- useIsDesktop,
46
37
  } from '../utils/common';
47
- import {useChangeDefaultLayout} from '../pages/video-call/DefaultLayouts';
48
38
  import {useRecording} from '../subComponents/recording/useRecording';
49
- import LayoutIconDropdown from '../subComponents/LayoutIconDropdown';
50
39
  import {useString} from '../utils/useString';
51
40
  import {useRoomInfo} from './room-info/useRoomInfo';
52
41
  import {useSidePanel} from '../utils/useSidePanel';
53
42
  import {ChatType, useChatUIControls} from './chat-ui/useChatUIControls';
54
- import LayoutIconButton from '../subComponents/LayoutIconButton';
55
- import {ToolbarPosition, useToolbar} from '../utils/useToolbar';
56
- import Styles from './styles';
57
43
  import IconButton, {IconButtonProps} from '../atoms/IconButton';
58
44
  import ThemeConfig from '../theme';
59
- import hexadecimalTransparency from '../utils/hexadecimalTransparency';
60
- import Spacer from '../atoms/Spacer';
61
- import {useLiveStreamDataContext} from './contexts/LiveStreamDataContext';
62
45
  import ParticipantsCount from '../atoms/ParticipantsCount';
63
- import styles from 'react-native-toast-message/src/styles';
64
46
  import RecordingInfo from '../atoms/RecordingInfo';
65
47
  import Toolbar from '../atoms/Toolbar';
66
- import ToolbarItem from '../atoms/ToolbarItem';
67
- import {ToolbarTopPresetProps, ToolbarItemHide} from '../atoms/ToolbarPreset';
48
+ import ToolbarItem, {useToolbarProps} from '../atoms/ToolbarItem';
49
+ import {
50
+ ToolbarItemHide,
51
+ ToolbarItemLabel,
52
+ TopToolbarItemsConfig,
53
+ ToolbarPresetProps,
54
+ } from '../atoms/ToolbarPreset';
68
55
  import {useToolbarMenu} from '../utils/useMenu';
69
56
  import ToolbarMenuItem from '../atoms/ToolbarMenuItem';
70
57
  import {useActionSheet} from '../utils/useActionSheet';
@@ -74,6 +61,7 @@ import {
74
61
  toolbarItemPeopleText,
75
62
  videoRoomRecordingText,
76
63
  } from '../language/default-labels/videoCallScreenLabels';
64
+ import {useLanguage} from '../language/useLanguage';
77
65
 
78
66
  export const ParticipantsCountView = ({
79
67
  isMobileView = false,
@@ -113,6 +101,7 @@ export interface ParticipantsIconButtonProps {
113
101
  render?: (onPress: () => void, isPanelActive: boolean) => JSX.Element;
114
102
  }
115
103
  export const ParticipantsIconButton = (props: ParticipantsIconButtonProps) => {
104
+ const {label = null, onPress: onPressCustom = null} = useToolbarProps();
116
105
  const {isToolbarMenuItem} = useToolbarMenu();
117
106
  const {
118
107
  liveStreamingRequestAlertIconPosition = {
@@ -124,8 +113,7 @@ export const ParticipantsIconButton = (props: ParticipantsIconButtonProps) => {
124
113
  } = props;
125
114
  const {isOnActionSheet, showLabel} = useActionSheet();
126
115
  const {sidePanel, setSidePanel} = useSidePanel();
127
- const {isPendingRequestToReview, setLastCheckedRequestTimestamp} =
128
- useContext(LiveStreamContext);
116
+ const {isPendingRequestToReview} = useContext(LiveStreamContext);
129
117
 
130
118
  const {waitingRoomUids} = useWaitingRoomContext();
131
119
  const participantsLabel = useString(toolbarItemPeopleText)();
@@ -144,7 +132,7 @@ export const ParticipantsIconButton = (props: ParticipantsIconButtonProps) => {
144
132
  //setLastCheckedRequestTimestamp(new Date().getTime());
145
133
  };
146
134
  let iconButtonProps: IconButtonProps = {
147
- onPress: onPress,
135
+ onPress: onPressCustom || onPress,
148
136
  iconProps: {
149
137
  name: 'participants',
150
138
  tintColor: isPanelActive
@@ -155,7 +143,7 @@ export const ParticipantsIconButton = (props: ParticipantsIconButtonProps) => {
155
143
  : '',
156
144
  },
157
145
  btnTextProps: {
158
- text: showLabel ? participantsLabel : '',
146
+ text: showLabel ? label || participantsLabel : '',
159
147
  textColor: $config.FONT_COLOR,
160
148
  },
161
149
  };
@@ -232,6 +220,7 @@ export interface ChatIconButtonProps {
232
220
  }
233
221
 
234
222
  export const ChatIconButton = (props: ChatIconButtonProps) => {
223
+ const {label = null, onPress: onPressCustom = null} = useToolbarProps();
235
224
  const {sidePanel, setSidePanel} = useSidePanel();
236
225
  const {isToolbarMenuItem} = useToolbarMenu();
237
226
  const {
@@ -242,13 +231,8 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
242
231
  bottom: undefined,
243
232
  zIndex: 999,
244
233
  },
245
- badgeTextStyle = {
246
- color: $config.PRIMARY_ACTION_TEXT_COLOR,
247
- fontSize: 12,
248
- textAlign: 'center',
249
- },
250
234
  } = props;
251
- const {setUnreadGroupMessageCount, totalUnreadCount} = useChatNotification();
235
+ const {totalUnreadCount} = useChatNotification();
252
236
  const {setChatType, setPrivateChatUser} = useChatUIControls();
253
237
 
254
238
  const chatLabel = useString(toolbarItemChatText)();
@@ -280,7 +264,7 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
280
264
  };
281
265
  const {isOnActionSheet, showLabel} = useActionSheet();
282
266
  let iconButtonProps: IconButtonProps = {
283
- onPress: onPress,
267
+ onPress: onPressCustom || onPress,
284
268
  iconProps: {
285
269
  name: 'chat-nav',
286
270
  tintColor: isPanelActive
@@ -291,20 +275,12 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
291
275
  : '',
292
276
  },
293
277
  btnTextProps: {
294
- text: showLabel ? chatLabel : '',
278
+ text: showLabel ? label || chatLabel : '',
295
279
  textColor: $config.FONT_COLOR,
296
280
  },
297
281
  };
298
282
 
299
283
  if (isOnActionSheet) {
300
- // iconButtonProps.containerStyle = {
301
- // backgroundColor: $config.CARD_LAYER_2_COLOR,
302
- // width: 52,
303
- // height: 52,
304
- // borderRadius: 26,
305
- // justifyContent: 'center',
306
- // alignItems: 'center',
307
- // };
308
284
  iconButtonProps.btnTextProps.textStyle = {
309
285
  color: $config.FONT_COLOR,
310
286
  marginTop: 8,
@@ -316,30 +292,6 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
316
292
  }
317
293
  iconButtonProps.isOnActionSheet = isOnActionSheet;
318
294
 
319
- // const renderBadgeOld = (badgeCount: any) => {
320
- // return (
321
- // <View
322
- // style={{
323
- // position: 'absolute',
324
- // top: badgeContainerPosition?.top,
325
- // bottom: badgeContainerPosition?.bottom,
326
- // left: badgeContainerPosition?.left,
327
- // right: badgeContainerPosition?.right,
328
- // borderRadius: 10,
329
- // width: 20,
330
- // height: 20,
331
- // backgroundColor: $config.PRIMARY_ACTION_BRAND_COLOR,
332
- // justifyContent: 'center',
333
- // }}>
334
- // <Text
335
- // style={{
336
- // ...badgeTextStyle,
337
- // }}>
338
- // {numFormatter(badgeCount)}
339
- // </Text>
340
- // </View>
341
- // );
342
- // };
343
295
  const renderUnreadMessageIndicator = () => {
344
296
  return (
345
297
  <View
@@ -353,7 +305,8 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
353
305
  width: 12,
354
306
  height: 12,
355
307
  backgroundColor: $config.SEMANTIC_ERROR,
356
- }}></View>
308
+ }}
309
+ />
357
310
  );
358
311
  };
359
312
  return props?.render ? (
@@ -374,17 +327,6 @@ export const ChatIconButton = (props: ChatIconButtonProps) => {
374
327
  );
375
328
  };
376
329
 
377
- interface LayoutIconButtonProps {
378
- modalPosition?: {
379
- top?: number;
380
- right?: number;
381
- left?: number;
382
- bottom?: number;
383
- };
384
-
385
- render?: (onPress: () => void) => JSX.Element;
386
- }
387
-
388
330
  export const SettingsIconButton = (props: SettingsIconButtonProps) => {
389
331
  return <Settings {...props} />;
390
332
  };
@@ -451,34 +393,34 @@ export const RecordingStatusToolbarItem = () => {
451
393
  );
452
394
  };
453
395
 
454
- export const ParticipantToolbarItem = () => {
396
+ export const ParticipantToolbarItem = props => {
455
397
  return (
456
- <ToolbarItem testID="videocall-participantsicon">
398
+ <ToolbarItem testID="videocall-participantsicon" toolbarProps={props}>
457
399
  <ParticipantsIconButton />
458
400
  </ToolbarItem>
459
401
  );
460
402
  };
461
403
 
462
- export const ChatToolbarItem = () => {
404
+ export const ChatToolbarItem = props => {
463
405
  return (
464
406
  $config.CHAT && (
465
407
  <>
466
- <ToolbarItem testID="videocall-chaticon">
408
+ <ToolbarItem testID="videocall-chaticon" toolbarProps={props}>
467
409
  <ChatIconButton />
468
410
  </ToolbarItem>
469
411
  </>
470
412
  )
471
413
  );
472
414
  };
473
- export const SettingsToobarItem = () => {
415
+ export const SettingsToobarItem = props => {
474
416
  return (
475
- <ToolbarItem testID="videocall-settingsicon">
417
+ <ToolbarItem testID="videocall-settingsicon" toolbarProps={props}>
476
418
  <SettingsIconButtonWithWrapper />
477
419
  </ToolbarItem>
478
420
  );
479
421
  };
480
422
 
481
- const defaultItems: ToolbarTopPresetProps['items'] = {
423
+ const defaultItems: TopToolbarItemsConfig = {
482
424
  'meeting-title': {
483
425
  align: 'start',
484
426
  component: MeetingTitleToolbarItem,
@@ -521,12 +463,13 @@ const defaultItems: ToolbarTopPresetProps['items'] = {
521
463
  };
522
464
 
523
465
  export interface NavbarProps {
524
- items?: ToolbarTopPresetProps['items'];
466
+ items?: ToolbarPresetProps['items'];
525
467
  includeDefaultItems?: boolean;
526
468
  }
527
469
  const Navbar = (props: NavbarProps) => {
528
470
  const {includeDefaultItems = true, items = {}} = props;
529
471
  const {width, height} = useWindowDimensions();
472
+ const {languageCode} = useLanguage();
530
473
 
531
474
  const isHidden = (hide: ToolbarItemHide = false) => {
532
475
  try {
@@ -563,6 +506,16 @@ const Navbar = (props: NavbarProps) => {
563
506
  const centerItemsOrdered = CustomToolbarSorting(centerItems);
564
507
  const endItemsOrdered = CustomToolbarSorting(endItems);
565
508
 
509
+ const customLabel = (labelParam: ToolbarItemLabel) => {
510
+ if (labelParam && typeof labelParam === 'string') {
511
+ return labelParam;
512
+ } else if (labelParam && typeof labelParam === 'function') {
513
+ return labelParam(languageCode);
514
+ } else {
515
+ return null;
516
+ }
517
+ };
518
+
566
519
  const renderContent = (
567
520
  orderedKeys: string[],
568
521
  type: 'start' | 'center' | 'end',
@@ -572,16 +525,28 @@ const Navbar = (props: NavbarProps) => {
572
525
  orderedKeys.forEach(keyName => {
573
526
  index = index + 1;
574
527
  let ToolbarComponent = null;
528
+ let label = null;
529
+ let onPress = null;
575
530
  if (type === 'start') {
576
531
  ToolbarComponent = startItems[keyName]?.component;
532
+ label = startItems[keyName]?.label;
533
+ onPress = startItems[keyName]?.onPress;
577
534
  } else if (type === 'center') {
578
535
  ToolbarComponent = centerItems[keyName]?.component;
536
+ label = centerItems[keyName]?.label;
537
+ onPress = centerItems[keyName]?.onPress;
579
538
  } else {
580
539
  ToolbarComponent = endItems[keyName]?.component;
540
+ label = endItems[keyName]?.label;
541
+ onPress = endItems[keyName]?.onPress;
581
542
  }
582
543
  if (ToolbarComponent) {
583
544
  renderContentItem.push(
584
- <ToolbarComponent key={`top-toolbar-${type}` + index} />,
545
+ <ToolbarComponent
546
+ key={`top-toolbar-${type}` + index}
547
+ label={customLabel(label)}
548
+ onPress={onPress}
549
+ />,
585
550
  );
586
551
  }
587
552
  });
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
2
  import {View, StyleSheet, useWindowDimensions} from 'react-native';
3
3
  import Toolbar from '../atoms/Toolbar';
4
- import {ToolbarItemHide, ToolbarTopPresetProps} from '../atoms/ToolbarPreset';
4
+ import {
5
+ ToolbarItemHide,
6
+ ToolbarItemLabel,
7
+ ToolbarPresetProps,
8
+ } from '../atoms/ToolbarPreset';
5
9
  import {
6
10
  MeetingTitleToolbarItem,
7
11
  ParticipantCountToolbarItem,
@@ -10,10 +14,11 @@ import {
10
14
  import {useRecording} from '../subComponents/recording/useRecording';
11
15
  import {CustomToolbarMerge, CustomToolbarSorting} from '../utils/common';
12
16
  import {filterObject} from '../utils';
17
+ import {useLanguage} from '../language/useLanguage';
13
18
 
14
19
  export interface NavbarProps {
15
20
  includeDefaultItems?: boolean;
16
- items?: ToolbarTopPresetProps['items'];
21
+ items?: ToolbarPresetProps['items'];
17
22
  }
18
23
 
19
24
  const NavbarMobile = (props: NavbarProps) => {
@@ -37,6 +42,7 @@ const NavbarMobile = (props: NavbarProps) => {
37
42
  };
38
43
  const {items = {}, includeDefaultItems = true} = props;
39
44
  const {width, height} = useWindowDimensions();
45
+ const {languageCode} = useLanguage();
40
46
 
41
47
  const isHidden = (hide: ToolbarItemHide = false) => {
42
48
  try {
@@ -63,18 +69,36 @@ const NavbarMobile = (props: NavbarProps) => {
63
69
 
64
70
  const startItemsOrdered = CustomToolbarSorting(startItems);
65
71
 
72
+ const getCustomLabel = (label: ToolbarItemLabel) => {
73
+ if (label && typeof label === 'string') {
74
+ return label;
75
+ } else if (label && typeof label === 'function') {
76
+ return label(languageCode);
77
+ } else {
78
+ return null;
79
+ }
80
+ };
81
+
66
82
  const renderContent = (orderedKeys: string[], type: 'start') => {
67
83
  const renderContentItem = [];
68
84
  let index = 0;
69
85
  orderedKeys.forEach(keyName => {
70
86
  index = index + 1;
71
87
  let ToolbarComponent = null;
88
+ let label = null;
89
+ let onPress = null;
72
90
  if (type === 'start') {
73
91
  ToolbarComponent = startItems[keyName]?.component;
92
+ label = startItems[keyName]?.label;
93
+ onPress = startItems[keyName]?.onPress;
74
94
  }
75
95
  if (ToolbarComponent) {
76
96
  renderContentItem.push(
77
- <ToolbarComponent key={`top-toolbar-${type}` + index} />,
97
+ <ToolbarComponent
98
+ key={`top-toolbar-${type}` + index}
99
+ label={getCustomLabel(label)}
100
+ onPress={onPress}
101
+ />,
78
102
  );
79
103
  }
80
104
  });
@@ -92,6 +92,15 @@ const PinnedVideo = ({renderData}) => {
92
92
  defaultContent[pinnedUid || maxUid]?.video &&
93
93
  defaultContent[pinnedUid || maxUid]?.type === 'screenshare';
94
94
 
95
+ //fixed issue on expand/collapse for screenshare
96
+ //screen will have the fullscreen functionality
97
+ useEffect(() => {
98
+ const maximizedUid = pinnedUid || maxUid;
99
+ if (getWhiteboardUid() != maximizedUid && collapse) {
100
+ setCollapse(false);
101
+ }
102
+ }, [isWhiteboard, collapse, pinnedUid, maxUid, getWhiteboardUid]);
103
+
95
104
  return (
96
105
  <View
97
106
  style={{
@@ -11,7 +11,7 @@
11
11
  */
12
12
  // @ts-nocheck
13
13
  import React, {useState, useContext, useEffect, useRef} from 'react';
14
- import RtmEngine from 'agora-react-native-rtm';
14
+ import RtmEngine, {RtmChannelAttribute} from 'agora-react-native-rtm';
15
15
  import {
16
16
  ContentInterface,
17
17
  DispatchContext,
@@ -233,6 +233,7 @@ const RtmConfigure = (props: any) => {
233
233
  }
234
234
  timerValueRef.current = 5;
235
235
  await getMembers();
236
+ await readAllChannelAttributes();
236
237
  logger.log(LogSource.AgoraSDK, 'Log', 'RTM getMembers done');
237
238
  } catch (error) {
238
239
  logger.error(
@@ -389,6 +390,42 @@ const RtmConfigure = (props: any) => {
389
390
  }
390
391
  };
391
392
 
393
+ const readAllChannelAttributes = async () => {
394
+ try {
395
+ await engine.current
396
+ .getChannelAttributes(rtcProps.channel)
397
+ .then(async data => {
398
+ for (const [key, value] of Object.entries(data?.attributes)) {
399
+ const {lastUpdateTs, lastUpdateUserId, value: payloadValue} = value;
400
+ if (hasJsonStructure(payloadValue as string)) {
401
+ const data = {
402
+ evt: key,
403
+ value: payloadValue,
404
+ };
405
+ // TODOSUP: Add the data to queue, dont add same mulitple events, use set so as to not repeat events
406
+ EventsQueue.enqueue({
407
+ data: data,
408
+ uid: lastUpdateUserId,
409
+ ts: lastUpdateTs,
410
+ });
411
+ }
412
+ }
413
+ logger.log(
414
+ LogSource.AgoraSDK,
415
+ 'API',
416
+ 'RTM getChannelAttributes data received',
417
+ data,
418
+ );
419
+ });
420
+ timerValueRef.current = 5;
421
+ } catch (error) {
422
+ setTimeout(async () => {
423
+ timerValueRef.current = timerValueRef.current + timerValueRef.current;
424
+ await readAllChannelAttributes();
425
+ }, timerValueRef.current * 1000);
426
+ }
427
+ };
428
+
392
429
  const init = async () => {
393
430
  logger.log(LogSource.AgoraSDK, 'Log', 'RTM creating engine...');
394
431
  engine.current = RTMEngine.getInstance().engine;
@@ -580,6 +617,37 @@ const RtmConfigure = (props: any) => {
580
617
  }
581
618
  }
582
619
  });
620
+
621
+ engine.current.on(
622
+ 'channelAttributesUpdated',
623
+ (attributeList: RtmChannelAttribute[]) => {
624
+ console.log('channel attributes updated', attributeList);
625
+ try {
626
+ attributeList.map((attribute: RtmChannelAttribute) => {
627
+ const {key, value, lastUpdateTs, lastUpdateUserId} = attribute;
628
+ const timestamp = getMessageTime(lastUpdateTs);
629
+ const sender = Platform.OS
630
+ ? get32BitUid(lastUpdateUserId)
631
+ : parseInt(lastUpdateUserId);
632
+ eventDispatcher(
633
+ {
634
+ evt: key,
635
+ value,
636
+ },
637
+ sender,
638
+ timestamp,
639
+ );
640
+ });
641
+ } catch (error) {
642
+ logger.error(
643
+ LogSource.Events,
644
+ 'CUSTOM_EVENTS',
645
+ 'error while dispatching through eventDispatcher',
646
+ error,
647
+ );
648
+ }
649
+ },
650
+ );
583
651
  await doLoginAndSetupRTM();
584
652
  };
585
653
 
@@ -9,9 +9,8 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import React, {useContext} from 'react';
13
- import {StyleSheet, View} from 'react-native';
14
- import ColorContext from './ColorContext';
12
+ import React from 'react';
13
+ import {View} from 'react-native';
15
14
  import {SidePanelType} from '../subComponents/SidePanelEnum';
16
15
  import {useSidePanel} from '../utils/useSidePanel';
17
16
  import {useString} from '../utils/useString';
@@ -20,15 +19,16 @@ import {useToolbarMenu} from '../utils/useMenu';
20
19
  import ToolbarMenuItem from '../atoms/ToolbarMenuItem';
21
20
  import {useActionSheet} from '../utils/useActionSheet';
22
21
  import {toolbarItemSettingText} from '../language/default-labels/videoCallScreenLabels';
22
+ import {useToolbarProps} from '../atoms/ToolbarItem';
23
23
 
24
24
  export interface SettingsIconButtonProps {
25
25
  render?: (onPress: () => void, isPanelActive: boolean) => JSX.Element;
26
26
  }
27
27
 
28
28
  const Settings = (props: SettingsIconButtonProps) => {
29
+ const {label = null, onPress: onPressCustom = null} = useToolbarProps();
29
30
  const {sidePanel, setSidePanel} = useSidePanel();
30
31
  const {isToolbarMenuItem} = useToolbarMenu();
31
- //commented for v1 release
32
32
  const settingsLabel = useString(toolbarItemSettingText)();
33
33
 
34
34
  const isPanelActive = sidePanel === SidePanelType.Settings;
@@ -39,7 +39,7 @@ const Settings = (props: SettingsIconButtonProps) => {
39
39
  };
40
40
  const {isOnActionSheet, showLabel} = useActionSheet();
41
41
  let iconButtonProps: IconButtonProps = {
42
- onPress: onPress,
42
+ onPress: onPressCustom || onPress,
43
43
 
44
44
  iconProps: {
45
45
  name: 'settings',
@@ -51,21 +51,12 @@ const Settings = (props: SettingsIconButtonProps) => {
51
51
  : '',
52
52
  },
53
53
  btnTextProps: {
54
- text: showLabel ? settingsLabel : '',
54
+ text: showLabel ? label || settingsLabel : '',
55
55
  textColor: $config.FONT_COLOR,
56
56
  },
57
57
  };
58
58
  iconButtonProps.isOnActionSheet = isOnActionSheet;
59
59
  if (isOnActionSheet) {
60
- // iconButtonProps.containerStyle = {
61
- // backgroundColor: $config.CARD_LAYER_2_COLOR,
62
- // width: 52,
63
- // height: 52,
64
- // borderRadius: 26,
65
- // justifyContent: 'center',
66
- // alignItems: 'center',
67
- // };
68
-
69
60
  iconButtonProps.btnTextProps.textStyle = {
70
61
  color: $config.FONT_COLOR,
71
62
  marginTop: 8,
@@ -94,18 +85,4 @@ export const SettingsWithViewWrapper = (props: SettingsIconButtonProps) => {
94
85
  return <Settings {...props} />;
95
86
  };
96
87
 
97
- const style = StyleSheet.create({
98
- localButton: {
99
- borderRadius: 2,
100
- borderColor: $config.PRIMARY_ACTION_BRAND_COLOR,
101
- width: 30,
102
- height: 30,
103
- display: 'flex',
104
- alignSelf: 'center',
105
- alignItems: 'center',
106
- justifyContent: 'center',
107
- resizeMode: 'contain',
108
- },
109
- });
110
-
111
88
  export default Settings;