bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/raisehand-notifier/container.jsx

64 lines
1.8 KiB
React
Raw Normal View History

import React from 'react';
import { useMutation } from '@apollo/client';
import RaiseHandNotifier from './component';
2023-12-07 03:30:30 +08:00
import { SET_RAISE_HAND } from '/imports/ui/core/graphql/mutations/userMutations';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { RAISED_HAND_USERS } from './queries';
2024-04-10 22:00:34 +08:00
import logger from '/imports/startup/client/logger';
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
import useSettings from '/imports/ui/services/settings/hooks/useSettings';
import { SETTINGS } from '/imports/ui/services/settings/enums';
const StatusNotifierContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
isModerator: user.isModerator,
}));
const isViewer = !currentUserData?.isModerator;
const isPresenter = currentUserData?.presenter;
2023-12-07 03:30:30 +08:00
const {
data: usersData,
error: usersError,
} = useDeduplicatedSubscription(RAISED_HAND_USERS);
const raiseHandUsers = usersData?.user || [];
if (usersError) {
2024-04-10 22:00:34 +08:00
logger.error({
logCode: 'raisehand_notifier_container_subscription_error',
extraInfo: { usersError },
}, 'Error on requesting raise hand data');
}
2023-12-07 03:30:30 +08:00
const [setRaiseHand] = useMutation(SET_RAISE_HAND);
const lowerUserHands = (userId) => {
setRaiseHand({
variables: {
userId,
raiseHand: false,
},
});
};
const {
raiseHandAudioAlerts,
raiseHandPushAlerts,
} = useSettings(SETTINGS.APPLICATION);
return (
<RaiseHandNotifier {...{
...props,
raiseHandAudioAlert: raiseHandAudioAlerts,
raiseHandPushAlert: raiseHandPushAlerts,
isViewer,
isPresenter,
2023-12-07 03:30:30 +08:00
lowerUserHands,
raiseHandUsers,
}}
/>
);
};
2020-06-30 10:43:20 +08:00
export default StatusNotifierContainer;