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

62 lines
1.7 KiB
React
Raw Normal View History

import React from 'react';
2020-06-30 10:43:20 +08:00
import { withTracker } from 'meteor/react-meteor-data';
import Settings from '/imports/ui/services/settings';
import { useMutation, useSubscription } 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';
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,
} = useSubscription(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,
},
});
};
return (
<RaiseHandNotifier {...{
...props,
isViewer,
isPresenter,
2023-12-07 03:30:30 +08:00
lowerUserHands,
raiseHandUsers,
}}
/>
);
};
2020-06-30 10:43:20 +08:00
export default withTracker(() => {
2020-06-30 10:43:20 +08:00
const AppSettings = Settings.application;
return {
raiseHandAudioAlert: AppSettings.raiseHandAudioAlerts,
raiseHandPushAlert: AppSettings.raiseHandPushAlerts,
};
})(StatusNotifierContainer);