Skip to content

Commit

Permalink
fix: use ts-pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn committed Mar 8, 2024
1 parent 0be8592 commit 54f0152
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { match, P } from 'ts-pattern';
import { HMSPeer, selectPermissions, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';

Expand All @@ -13,13 +14,17 @@ export const useGroupOnStageActions = ({ peers }: { peers: HMSPeer[] }) => {
} = elements.on_stage_exp || {};
const canChangeRole = useHMSStore(selectPermissions)?.changeRole;

const offStageRolePeers = peers.filter(
peer =>
on_stage_role &&
bring_to_stage_label &&
peer.roleName &&
off_stage_roles?.includes(peer.roleName) &&
!(peer.roleName === on_stage_role),
const offStageRolePeers = peers.filter(peer =>
match({ on_stage_role, bring_to_stage_label, roleName: peer.roleName })
.with(
{
on_stage_role: P.when(role => !!role),
bring_to_stage_label: P.when(label => !!label),
roleName: P.when(role => !!role && off_stage_roles.includes(role)),
},
() => true,
)
.otherwise(() => false),
);

const lowerAllHands = async () => {
Expand Down

0 comments on commit 54f0152

Please sign in to comment.