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

48 lines
1.5 KiB
React
Raw Normal View History

import React, { useContext } 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';
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
2020-06-30 10:43:20 +08:00
import { makeCall } from '/imports/ui/services/api';
import RaiseHandNotifier from './component';
2020-06-30 10:43:20 +08:00
const ROLE_VIEWER = Meteor.settings.public.user.role_viewer;
const StatusNotifierContainer = (props) => {
const usingUsersContext = useContext(UsersContext);
const { users } = usingUsersContext;
2021-04-15 20:12:21 +08:00
const currentUser = users[Auth.meetingID][Auth.userID];
const isViewer = currentUser.role === ROLE_VIEWER;
const isPresenter = currentUser.presenter;
return (
<RaiseHandNotifier {...{
...props,
isViewer,
isPresenter,
}}
/>
);
};
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();
const lowerUserHands = (userId) => makeCall('changeRaiseHand', false, userId);
2020-06-30 10:43:20 +08:00
return {
lowerUserHands,
raiseHandUsers,
2020-06-30 10:43:20 +08:00
raiseHandAudioAlert: AppSettings.raiseHandAudioAlerts,
raiseHandPushAlert: AppSettings.raiseHandPushAlerts,
};
})(StatusNotifierContainer);