2024-01-16 03:49:09 +08:00
|
|
|
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,
|
|
|
|
}));
|
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
const ROLE_MODERATOR = window.meetingClientSettings.public.user.role_moderator;
|
|
|
|
|
2024-01-16 03:49:09 +08:00
|
|
|
if (currentUserData?.role === ROLE_MODERATOR) return true;
|
|
|
|
|
|
|
|
if (currentUserData?.locked) {
|
|
|
|
return !meetingData?.lockSettings?.disableNotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default useHasPermission;
|