2021-04-07 03:58:11 +08:00
|
|
|
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';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Users from '/imports/api/users';
|
2020-06-30 10:43:20 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2021-04-07 03:58:11 +08:00
|
|
|
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';
|
2023-06-08 09:10:07 +08:00
|
|
|
import RaiseHandNotifier from './component';
|
2020-06-30 10:43:20 +08:00
|
|
|
|
2020-07-06 20:56:19 +08:00
|
|
|
const ROLE_VIEWER = Meteor.settings.public.user.role_viewer;
|
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
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];
|
2021-04-07 03:58:11 +08:00
|
|
|
const isViewer = currentUser.role === ROLE_VIEWER;
|
2021-09-27 19:29:49 +08:00
|
|
|
const isPresenter = currentUser.presenter;
|
2021-04-07 03:58:11 +08:00
|
|
|
return (
|
2023-06-08 09:10:07 +08:00
|
|
|
<RaiseHandNotifier {...{
|
2021-04-07 03:58:11 +08:00
|
|
|
...props,
|
|
|
|
isViewer,
|
2021-09-27 19:29:49 +08:00
|
|
|
isPresenter,
|
2021-04-07 03:58:11 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2020-06-30 10:43:20 +08:00
|
|
|
|
2023-06-08 09:10:07 +08:00
|
|
|
export default withTracker(() => {
|
2020-06-30 10:43:20 +08:00
|
|
|
const AppSettings = Settings.application;
|
2023-06-08 09:10:07 +08:00
|
|
|
const raiseHandUsers = Users.find({
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
raiseHand: true,
|
|
|
|
}, {
|
2020-06-30 10:43:20 +08:00
|
|
|
fields: {
|
2023-06-08 09:10:07 +08:00
|
|
|
raiseHandTime: 1, raiseHand: 1, userId: 1, name: 1, color: 1, role: 1, avatar: 1,
|
2020-06-30 10:43:20 +08:00
|
|
|
},
|
2023-06-08 09:10:07 +08:00
|
|
|
sort: { raiseHandTime: 1 },
|
|
|
|
}).fetch();
|
|
|
|
const lowerUserHands = (userId) => makeCall('changeRaiseHand', false, userId);
|
2020-06-30 10:43:20 +08:00
|
|
|
|
|
|
|
return {
|
2023-06-08 09:10:07 +08:00
|
|
|
lowerUserHands,
|
|
|
|
raiseHandUsers,
|
2020-06-30 10:43:20 +08:00
|
|
|
raiseHandAudioAlert: AppSettings.raiseHandAudioAlerts,
|
|
|
|
raiseHandPushAlert: AppSettings.raiseHandPushAlerts,
|
|
|
|
};
|
|
|
|
})(StatusNotifierContainer);
|