@100mslive/roomkit-react 0.3.2-alpha.0 → 0.3.2-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-C5XHK2VY.js → HLSView-SF6SAQ5J.js} +2 -2
- package/dist/Prebuilt/components/Footer/ParticipantList.d.ts +2 -1
- package/dist/Prebuilt/components/Footer/RoleAccordion.d.ts +1 -0
- package/dist/Prebuilt/components/hooks/useGroupOnStageActions.d.ts +10 -0
- package/dist/Prebuilt/components/hooks/usePeerOnStageActions.d.ts +14 -0
- package/dist/{chunk-E7AEJ446.js → chunk-OYWNLHYU.js} +607 -490
- package/dist/chunk-OYWNLHYU.js.map +7 -0
- package/dist/index.cjs.js +1968 -1839
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +323 -210
- package/dist/meta.esbuild.json +136 -23
- package/package.json +7 -6
- package/src/Prebuilt/components/Footer/ParticipantList.tsx +90 -66
- package/src/Prebuilt/components/Footer/RoleAccordion.tsx +20 -1
- package/src/Prebuilt/components/MwebLandscapePrompt.tsx +1 -1
- package/src/Prebuilt/components/VideoLayouts/ProminenceLayout.tsx +0 -1
- package/src/Prebuilt/components/hooks/useGroupOnStageActions.tsx +54 -0
- package/src/Prebuilt/components/hooks/usePeerOnStageActions.tsx +49 -0
- package/src/Prebuilt/layouts/SidePane.tsx +0 -1
- package/dist/chunk-E7AEJ446.js.map +0 -7
- /package/dist/{HLSView-C5XHK2VY.js.map → HLSView-SF6SAQ5J.js.map} +0 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
import { match, P } from 'ts-pattern';
|
2
|
+
import { HMSPeer, selectPermissions, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
|
3
|
+
import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
|
4
|
+
|
5
|
+
export const useGroupOnStageActions = ({ peers }: { peers: HMSPeer[] }) => {
|
6
|
+
const hmsActions = useHMSActions();
|
7
|
+
const { elements } = useRoomLayoutConferencingScreen();
|
8
|
+
const {
|
9
|
+
bring_to_stage_label,
|
10
|
+
remove_from_stage_label,
|
11
|
+
on_stage_role,
|
12
|
+
off_stage_roles = [],
|
13
|
+
skip_preview_for_role_change = false,
|
14
|
+
} = elements.on_stage_exp || {};
|
15
|
+
const canChangeRole = useHMSStore(selectPermissions)?.changeRole;
|
16
|
+
|
17
|
+
const offStageRolePeers = peers.filter(peer =>
|
18
|
+
match({ on_stage_role, bring_to_stage_label, roleName: peer.roleName })
|
19
|
+
.with(
|
20
|
+
{
|
21
|
+
on_stage_role: P.when(role => !!role),
|
22
|
+
bring_to_stage_label: P.when(label => !!label),
|
23
|
+
roleName: P.when(role => !!role && off_stage_roles.includes(role)),
|
24
|
+
},
|
25
|
+
() => true,
|
26
|
+
)
|
27
|
+
.otherwise(() => false),
|
28
|
+
);
|
29
|
+
|
30
|
+
const lowerAllHands = async () => {
|
31
|
+
return Promise.all(peers.map(peer => hmsActions.lowerRemotePeerHand(peer.id)));
|
32
|
+
};
|
33
|
+
|
34
|
+
const bringAllToStage = () => {
|
35
|
+
if (!canChangeRole || !on_stage_role) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
return Promise.all(
|
39
|
+
offStageRolePeers.map(peer => {
|
40
|
+
return hmsActions.changeRoleOfPeer(peer.id, on_stage_role, skip_preview_for_role_change).then(() => {
|
41
|
+
return skip_preview_for_role_change ? hmsActions.lowerRemotePeerHand(peer.id) : null;
|
42
|
+
});
|
43
|
+
}),
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
return {
|
48
|
+
lowerAllHands,
|
49
|
+
bringAllToStage,
|
50
|
+
canBringToStage: canChangeRole && offStageRolePeers.length > 0,
|
51
|
+
bring_to_stage_label,
|
52
|
+
remove_from_stage_label,
|
53
|
+
};
|
54
|
+
};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { useState } from 'react';
|
2
|
+
import { selectPeerMetadata, selectPermissions, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
|
3
|
+
import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
|
4
|
+
|
5
|
+
export const usePeerOnStageActions = ({ peerId, role }: { peerId: string; role: string }) => {
|
6
|
+
const hmsActions = useHMSActions();
|
7
|
+
const { elements } = useRoomLayoutConferencingScreen();
|
8
|
+
const {
|
9
|
+
bring_to_stage_label,
|
10
|
+
remove_from_stage_label,
|
11
|
+
on_stage_role,
|
12
|
+
off_stage_roles = [],
|
13
|
+
skip_preview_for_role_change = false,
|
14
|
+
} = elements.on_stage_exp || {};
|
15
|
+
const isInStage = role === on_stage_role;
|
16
|
+
const canChangeRole = useHMSStore(selectPermissions)?.changeRole;
|
17
|
+
const shouldShowStageRoleChange =
|
18
|
+
canChangeRole &&
|
19
|
+
((isInStage && remove_from_stage_label) || (off_stage_roles?.includes(role) && bring_to_stage_label));
|
20
|
+
const prevRole = useHMSStore(selectPeerMetadata(peerId))?.prevRole;
|
21
|
+
const [open, setOpen] = useState(false);
|
22
|
+
|
23
|
+
const lowerPeerHand = async () => {
|
24
|
+
await hmsActions.lowerRemotePeerHand(peerId);
|
25
|
+
};
|
26
|
+
|
27
|
+
const handleStageAction = async () => {
|
28
|
+
if (isInStage) {
|
29
|
+
prevRole && hmsActions.changeRoleOfPeer(peerId, prevRole, true);
|
30
|
+
} else if (on_stage_role) {
|
31
|
+
await hmsActions.changeRoleOfPeer(peerId, on_stage_role, skip_preview_for_role_change);
|
32
|
+
if (skip_preview_for_role_change) {
|
33
|
+
await lowerPeerHand();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
setOpen(false);
|
37
|
+
};
|
38
|
+
|
39
|
+
return {
|
40
|
+
open,
|
41
|
+
setOpen,
|
42
|
+
lowerPeerHand,
|
43
|
+
handleStageAction,
|
44
|
+
shouldShowStageRoleChange,
|
45
|
+
isInStage,
|
46
|
+
bring_to_stage_label,
|
47
|
+
remove_from_stage_label,
|
48
|
+
};
|
49
|
+
};
|