bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/raisehand-notifier/container.jsx
Tainan Felipe 3bc40df230
Add: useDeduplicatedSubscription hook (#20376)
* Add: useDeduplicatedSubscription hook

* Fix: TS error

* Add: components using useDeduplicatedSubscription

* Change: Move to useDeduplicatedSubscription

* Change: unsubscribe logic to own useEffect

* Change: remove file import over package

* Fix: TS errors

* Fix: private chat not loading

* Change: revert changes on queries

* Fix: eslint error

* Remove: html-webpack-plugin package

* Fix: external video

* Add: comment about the stringToHash function

* Fix: video player showing tools over presentation
2024-06-04 10:40:54 -03:00

64 lines
1.8 KiB
JavaScript

import React from 'react';
import { useMutation } from '@apollo/client';
import RaiseHandNotifier from './component';
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';
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;
const {
data: usersData,
error: usersError,
} = useDeduplicatedSubscription(RAISED_HAND_USERS);
const raiseHandUsers = usersData?.user || [];
if (usersError) {
logger.error({
logCode: 'raisehand_notifier_container_subscription_error',
extraInfo: { usersError },
}, 'Error on requesting raise hand data');
}
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,
lowerUserHands,
raiseHandUsers,
}}
/>
);
};
export default StatusNotifierContainer;