agora-appbuilder-core 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "vercel-build": "npm run dev-setup && cd template && npm run web:build && cd .. && npm run copy-vercel",
12
- "uikit": "rm -rf template/agora-rn-uikit && git clone https://github.com/AgoraIO-Community/ReactNative-UIKit.git template/agora-rn-uikit && cd template/agora-rn-uikit && git checkout release/fpe-1.0.0",
12
+ "uikit": "rm -rf template/agora-rn-uikit && git clone https://github.com/AgoraIO-Community/ReactNative-UIKit.git template/agora-rn-uikit && cd template/agora-rn-uikit && git checkout release/fpe-1.0.1",
13
13
  "deps": "cd template && npm i",
14
14
  "dev-setup": "npm run uikit && npm run deps && node devSetup.js",
15
15
  "web-build": "cd template && npm run web:build && cd .. && npm run copy-vercel",
@@ -12,6 +12,7 @@ export interface RenderObjects {
12
12
  export interface RenderStateInterface {
13
13
  renderList: RenderObjects;
14
14
  activeUids: Array<UidType>;
15
+ lastJoinedUid?: UidType;
15
16
  }
16
17
 
17
18
  export interface ActionInterface<T extends keyof CallbacksInterface> {
@@ -46,28 +46,14 @@ export default function UserJoined(
46
46
  stateUpdate = {
47
47
  renderList: renderList,
48
48
  activeUids: activeUids.reverse(),
49
- lastJoinedUser: {
50
- ...state.renderList[newUid],
51
- uid: newUid,
52
- audio: ToggleState.disabled,
53
- video: ToggleState.disabled,
54
- streamType: dualStreamMode === DualStreamMode.HIGH ? 'high' : 'low', // Low if DualStreamMode is LOW or DYNAMIC by default,
55
- ...typeData,
56
- },
49
+ lastJoinedUid: newUid,
57
50
  };
58
51
  } else {
59
52
  //More than one remote
60
53
  stateUpdate = {
61
54
  renderList: renderList,
62
55
  activeUids: activeUids,
63
- lastJoinedUser: {
64
- ...state.renderList[newUid],
65
- uid: newUid,
66
- audio: ToggleState.disabled,
67
- video: ToggleState.disabled,
68
- streamType: dualStreamMode === DualStreamMode.HIGH ? 'high' : 'low', // Low if DualStreamMode is LOW or DYNAMIC by default,
69
- ...typeData,
70
- },
56
+ lastJoinedUid: newUid,
71
57
  };
72
58
  }
73
59
 
@@ -13,7 +13,6 @@ import PropsContext, {
13
13
  DualStreamMode,
14
14
  } from './Contexts/PropsContext';
15
15
  import {RenderProvider} from './Contexts/RenderContext';
16
- import {LastJoinedUserProvider} from './Contexts/LastJoinedUserContext';
17
16
  import {actionTypeGuard} from './Utils/actionTypeGuard';
18
17
 
19
18
  import {
@@ -48,6 +47,7 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
48
47
  },
49
48
  },
50
49
  activeUids: [localUid],
50
+ lastJoinedUid: 0,
51
51
  };
52
52
 
53
53
  const [initialState, setInitialState] = React.useState(
@@ -322,11 +322,9 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
322
322
  value={{
323
323
  renderList: uidState.renderList,
324
324
  activeUids: uidState.activeUids,
325
+ lastJoinedUid: uidState.lastJoinedUid,
325
326
  }}>
326
- <LastJoinedUserProvider
327
- value={{lastUserJoined: uidState.lastJoinedUser}}>
328
- {props.children}
329
- </LastJoinedUserProvider>
327
+ {props.children}
330
328
  </RenderProvider>
331
329
  </RtcProvider>
332
330
  </Join>
@@ -10,11 +10,7 @@ export {
10
10
  LocalProvider,
11
11
  LocalContext,
12
12
  } from './Contexts/LocalUserContext';
13
- export {
14
- default as LastJoinedUserContext,
15
- LastJoinedUserConsumer,
16
- LastJoinedUserProvider,
17
- } from './Contexts/LastJoinedUserContext';
13
+
18
14
  export {
19
15
  default as RenderContext,
20
16
  RenderConsumer,
@@ -2,11 +2,7 @@
2
2
  * Core contexts
3
3
  */
4
4
  import {createHook} from 'customization-implementation';
5
- import {
6
- RtcContext,
7
- RenderContext,
8
- LastJoinedUserContext,
9
- } from '../agora-rn-uikit';
5
+ import {RtcContext, RenderContext} from '../agora-rn-uikit';
10
6
 
11
7
  // commented for v1 release
12
8
  //import {default as DeviceContext} from '../src/components/DeviceContext';
@@ -20,7 +16,6 @@ export const useRtc = createHook(RtcContext);
20
16
  */
21
17
  export const useRender = createHook(RenderContext);
22
18
 
23
- export const useLastJoinedUser = createHook(LastJoinedUserContext);
24
19
  export {useLocalUserInfo} from '../src/app-state/useLocalUserInfo';
25
20
 
26
21
  // commented for v1 release
@@ -22,17 +22,13 @@ import {useScreenContext} from '../../components/contexts/ScreenShareContext';
22
22
  import {useString} from '../../utils/useString';
23
23
  import events from '../../rtm-events-api';
24
24
  import {EventNames, EventActions} from '../../rtm-events';
25
- import {
26
- useLastJoinedUser,
27
- useLayout,
28
- useRender,
29
- useRtc,
30
- } from 'customization-api';
25
+ import {useLayout, useRender, useRtc} from 'customization-api';
26
+ import {filterObject} from '../../utils';
31
27
 
32
28
  export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
33
29
  const {dispatch} = useRtc();
34
- const {renderList, activeUids} = useRender();
35
- const {lastUserJoined: lastJoinedUser} = useLastJoinedUser();
30
+ const {renderList, activeUids, lastJoinedUid} = useRender();
31
+ const isPinned = useRef(0);
36
32
  const {setScreenShareData, screenShareData} = useScreenContext();
37
33
  // commented for v1 release
38
34
  // const getScreenShareName = useString('screenshareUserName');
@@ -53,29 +49,52 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
53
49
  currentLayoutRef.current.currentLayout = currentLayout;
54
50
  }, [currentLayout]);
55
51
 
52
+ // useEffect(() => {
53
+ // if (
54
+ // lastJoinedUid &&
55
+ // activeUids &&
56
+ // activeUids.indexOf(lastJoinedUid) !== -1 &&
57
+ // renderListRef.current.renderList[lastJoinedUid] &&
58
+ // renderListRef.current.renderList[lastJoinedUid].type === 'screenshare' &&
59
+ // isPinned.current !== lastJoinedUid
60
+ // ) {
61
+ // //set to pinned layout
62
+ // //triggerChangeLayout(true, lastJoinedUid);
63
+ // }
64
+ // }, [lastJoinedUid, activeUids, renderListRef.current.renderList]);
65
+
56
66
  useEffect(() => {
57
- if (
58
- lastJoinedUser &&
59
- lastJoinedUser?.uid &&
60
- lastJoinedUser?.type === 'screenshare' &&
61
- activeUids &&
62
- activeUids.indexOf(lastJoinedUser.uid) !== -1
63
- ) {
64
- //set to pinned layout
65
- triggerChangeLayout(true, lastJoinedUser.uid);
67
+ const data = filterObject(screenShareData, ([k, v]) => v?.isActive);
68
+ if (data) {
69
+ const recentScreenshare = Object.keys(data)
70
+ .map((i) => parseInt(i))
71
+ .sort((a, b) => {
72
+ return data[a].ts - data[b].ts;
73
+ });
74
+ if (recentScreenshare?.length) {
75
+ recentScreenshare.reverse();
76
+ if (
77
+ isPinned.current !== recentScreenshare[0] &&
78
+ activeUids.indexOf(recentScreenshare[0]) !== -1
79
+ ) {
80
+ triggerChangeLayout(true, recentScreenshare[0]);
81
+ }
82
+ }
66
83
  }
67
- }, [lastJoinedUser, activeUids]);
84
+ }, [activeUids, screenShareData]);
68
85
 
69
86
  const triggerChangeLayout = (pinned: boolean, screenShareUid?: UidType) => {
70
87
  let layout = currentLayoutRef.current.currentLayout;
71
88
  //screenshare is started set the layout to Pinned View
72
89
  if (pinned && screenShareUid) {
90
+ isPinned.current = screenShareUid;
73
91
  dispatch({
74
92
  type: 'SwapVideo',
75
93
  value: [screenShareUid],
76
94
  });
77
95
  layout !== getPinnedLayoutName() && setPinnedLayout();
78
96
  } else {
97
+ isPinned.current = 0;
79
98
  //screenshare is stopped set the layout Grid View
80
99
  layout !== getGridLayoutName() && changeLayout();
81
100
  }
@@ -26,12 +26,8 @@ import {IAgoraRTC} from 'agora-rtc-sdk-ng';
26
26
  import useRecordingLayoutQuery from '../recording/useRecordingLayoutQuery';
27
27
  import {useString} from '../../utils/useString';
28
28
  import {timeNow} from '../../rtm/utils';
29
- import {
30
- useLastJoinedUser,
31
- useLayout,
32
- useRender,
33
- useRtc,
34
- } from 'customization-api';
29
+ import {useLayout, useRender, useRtc} from 'customization-api';
30
+ import {filterObject} from '../../utils';
35
31
 
36
32
  export const ScreenshareContextConsumer = ScreenshareContext.Consumer;
37
33
 
@@ -39,9 +35,8 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
39
35
  const [isScreenshareActive, setScreenshareActive] = useState(false);
40
36
  const rtc = useRtc();
41
37
  const {dispatch} = rtc;
42
- const {renderList, activeUids} = useRender();
43
- const {lastUserJoined: lastJoinedUser} = useLastJoinedUser();
44
-
38
+ const {renderList, activeUids, lastJoinedUid} = useRender();
39
+ const isPinned = useRef(0);
45
40
  const {isRecordingActive} = useRecording();
46
41
  const {executeNormalQuery, executePresenterQuery} = useRecordingLayoutQuery();
47
42
  const {setScreenShareData, screenShareData} = useScreenContext();
@@ -71,31 +66,56 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
71
66
  /**
72
67
  * Event api callback trigger even before screenshare data available in the RTC layer.
73
68
  * so instead of calling triggerChangeLayout from the event api call back
74
- * listening for rtc layout lastJoinedUser data and if its screenshare then call triggerChangeLayout
69
+ * listening for rtc layout lastJoinedUid data and if its screenshare then call triggerChangeLayout
70
+ * lastJoinedUid will be coming from the user joined event
71
+ * cross check lastJoinedUid data with renderlist
75
72
  */
73
+ // useEffect(() => {
74
+ // if (
75
+ // lastJoinedUid &&
76
+ // activeUids &&
77
+ // activeUids.indexOf(lastJoinedUid) !== -1 &&
78
+ // renderListRef.current.renderList[lastJoinedUid] &&
79
+ // renderListRef.current.renderList[lastJoinedUid].type === 'screenshare' &&
80
+ // isPinned.current !== lastJoinedUid
81
+ // ) {
82
+ // //set to pinned layout
83
+ // // triggerChangeLayout(true, lastJoinedUid);
84
+ // }
85
+ // }, [lastJoinedUid, activeUids, renderListRef.current.renderList]);
86
+
76
87
  useEffect(() => {
77
- if (
78
- lastJoinedUser &&
79
- lastJoinedUser?.uid &&
80
- lastJoinedUser?.type === 'screenshare' &&
81
- activeUids &&
82
- activeUids.indexOf(lastJoinedUser.uid) !== -1
83
- ) {
84
- //set to pinned layout
85
- triggerChangeLayout(true, lastJoinedUser.uid);
88
+ const data = filterObject(screenShareData, ([k, v]) => v?.isActive);
89
+ if (data) {
90
+ const recentScreenshare = Object.keys(data)
91
+ .map((i) => parseInt(i))
92
+ .sort((a, b) => {
93
+ return data[a].ts - data[b].ts;
94
+ });
95
+ if (recentScreenshare?.length) {
96
+ recentScreenshare.reverse();
97
+ if (
98
+ isPinned.current !== recentScreenshare[0] &&
99
+ activeUids.indexOf(recentScreenshare[0]) !== -1
100
+ ) {
101
+ triggerChangeLayout(true, recentScreenshare[0]);
102
+ }
103
+ }
86
104
  }
87
- }, [lastJoinedUser, activeUids]);
105
+ }, [activeUids, screenShareData]);
88
106
 
89
107
  const triggerChangeLayout = (pinned: boolean, screenShareUid?: UidType) => {
90
108
  let layout = currentLayoutRef.current.currentLayout;
91
109
  //screenshare is started set the layout to Pinned View
92
110
  if (pinned && screenShareUid) {
111
+ isPinned.current = screenShareUid;
93
112
  dispatch({
94
113
  type: 'SwapVideo',
95
114
  value: [screenShareUid],
96
115
  });
97
116
  layout !== getPinnedLayoutName() && setPinnedLayout();
98
117
  } else {
118
+ isPinned.current = 0;
99
119
  //screenshare is stopped set the layout Grid View
100
120
  layout !== getGridLayoutName() && changeLayout();
101
121
  }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import {RenderInterface} from './PropsContext';
3
-
4
- const LastJoinedUserContext = React.createContext<{
5
- lastUserJoined?: RenderInterface;
6
- }>({});
7
-
8
- export const LastJoinedUserProvider = LastJoinedUserContext.Provider;
9
- export const LastJoinedUserConsumer = LastJoinedUserContext.Consumer;
10
- export default LastJoinedUserContext;