2019-11-02 03:29:33 +08:00
|
|
|
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 Users from '/imports/api/users';
|
|
|
|
import TalkingIndicator from './component';
|
2019-11-06 01:10:59 +08:00
|
|
|
import Service from './service';
|
2019-11-02 03:29:33 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
const usersTalking = VoiceUsers.find({ meetingId, joined: true, spoke: true }, {
|
|
|
|
fields: {
|
|
|
|
callerName: 1,
|
|
|
|
talking: 1,
|
2019-11-06 01:10:59 +08:00
|
|
|
color: 1,
|
|
|
|
startTime: 1,
|
2019-11-02 03:29:33 +08:00
|
|
|
},
|
2019-11-06 01:10:59 +08:00
|
|
|
}).fetch().sort(Service.sortVoiceUsers);
|
2019-11-02 03:29:33 +08:00
|
|
|
|
|
|
|
if (usersTalking) {
|
|
|
|
usersTalking.forEach((user) => {
|
2019-11-06 01:10:59 +08:00
|
|
|
const { callerName, talking, color } = user;
|
|
|
|
talkers[`${callerName}`] = {
|
|
|
|
color,
|
|
|
|
talking,
|
|
|
|
};
|
2019-11-02 03:29:33 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
talkers,
|
|
|
|
};
|
|
|
|
})(TalkingIndicatorContainer);
|