bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/nav-bar/talking-indicator/container.jsx

62 lines
1.5 KiB
React
Raw Normal View History

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import VoiceUsers from '/imports/api/voice-users';
import Auth from '/imports/ui/services/auth';
import TalkingIndicator from './component';
import { makeCall } from '/imports/ui/services/api';
2019-11-20 23:08:36 +08:00
import Service from './service';
const APP_CONFIG = Meteor.settings.public.app;
const { enableTalkingIndicator } = APP_CONFIG;
const TalkingIndicatorContainer = (props) => {
if (!enableTalkingIndicator) return null;
return (<TalkingIndicator {...props} />);
};
export default withTracker(() => {
const talkers = {};
const meetingId = Auth.meetingID;
2019-11-14 00:24:38 +08:00
const usersTalking = VoiceUsers.find({ meetingId, joined: true, spoke: true }, {
fields: {
callerName: 1,
talking: 1,
color: 1,
startTime: 1,
voiceUserId: 1,
muted: 1,
},
2019-11-20 23:08:36 +08:00
}).fetch().sort(Service.sortVoiceUsers);
if (usersTalking) {
2019-11-06 04:19:50 +08:00
for (let i = 0; i < usersTalking.length; i += 1) {
const {
callerName, talking, color, voiceUserId, muted,
} = usersTalking[i];
talkers[`${callerName}`] = {
color,
talking,
voiceUserId,
muted,
};
2019-11-06 04:19:50 +08:00
}
}
const muteUser = (id) => {
const user = VoiceUsers.findOne({ meetingId, voiceUserId: id }, {
fields: {
muted: 1,
},
});
if (user.muted) return;
makeCall('toggleVoice', id);
};
return {
talkers,
muteUser,
2019-11-26 03:24:12 +08:00
openPanel: Session.get('openPanel'),
};
})(TalkingIndicatorContainer);