bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/notes/hooks/useHasPermission.ts
Ramón Souza 7514066fc3
fix: Client can't load in certain cases (#20336)
* move settings

* remove meteor cache files
2024-05-29 09:26:11 -04:00

25 lines
653 B
TypeScript

import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import useMeeting from '/imports/ui/core/hooks/useMeeting';
const useHasPermission = () => {
const { data: currentUserData } = useCurrentUser((u) => ({
locked: u.locked,
role: u.role,
}));
const { data: meetingData } = useMeeting((m) => ({
lockSettings: m.lockSettings,
}));
const ROLE_MODERATOR = window.meetingClientSettings.public.user.role_moderator;
if (currentUserData?.role === ROLE_MODERATOR) return true;
if (currentUserData?.locked) {
return !meetingData?.lockSettings?.disableNotes;
}
return true;
};
export default useHasPermission;