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

60 lines
1.6 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 Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
2020-06-30 10:43:20 +08:00
import Settings from '/imports/ui/services/settings';
2023-12-07 03:30:30 +08:00
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';
2020-06-30 10:43:20 +08:00
const ROLE_VIEWER = Meteor.settings.public.user.role_viewer;
const StatusNotifierContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
role: user.role,
}));
const isViewer = currentUserData?.role === ROLE_VIEWER;
const isPresenter = currentUserData?.presenter;
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,
}}
/>
);
};
2020-06-30 10:43:20 +08:00
export default withTracker(() => {
2020-06-30 10:43:20 +08:00
const AppSettings = Settings.application;
const raiseHandUsers = Users.find({
meetingId: Auth.meetingID,
raiseHand: true,
}, {
2020-06-30 10:43:20 +08:00
fields: {
raiseHandTime: 1, raiseHand: 1, userId: 1, name: 1, color: 1, role: 1, avatar: 1,
2020-06-30 10:43:20 +08:00
},
sort: { raiseHandTime: 1 },
}).fetch();
2020-06-30 10:43:20 +08:00
return {
raiseHandUsers,
2020-06-30 10:43:20 +08:00
raiseHandAudioAlert: AppSettings.raiseHandAudioAlerts,
raiseHandPushAlert: AppSettings.raiseHandPushAlerts,
};
})(StatusNotifierContainer);