2022-12-08 03:47:31 +08:00
|
|
|
import React, { useContext } from 'react';
|
2019-11-02 03:29:33 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
|
|
import VoiceUsers from '/imports/api/voice-users';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2023-08-10 00:12:29 +08:00
|
|
|
import { debounce } from '/imports/utils/debounce';
|
2019-11-02 03:29:33 +08:00
|
|
|
import TalkingIndicator from './component';
|
2019-11-14 01:56:26 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2020-11-20 03:12:05 +08:00
|
|
|
import { meetingIsBreakout } from '/imports/ui/components/app/service';
|
2021-09-11 04:48:52 +08:00
|
|
|
import { layoutSelectInput, layoutDispatch } from '../../layout/context';
|
2022-04-14 21:59:54 +08:00
|
|
|
import SpeechService from '/imports/ui/components/audio/captions/speech/service';
|
2022-12-08 03:47:31 +08:00
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
2019-11-02 03:29:33 +08:00
|
|
|
|
|
|
|
const APP_CONFIG = Meteor.settings.public.app;
|
|
|
|
const { enableTalkingIndicator } = APP_CONFIG;
|
2021-01-26 09:01:26 +08:00
|
|
|
const TALKING_INDICATOR_MUTE_INTERVAL = 500;
|
2021-10-08 22:13:37 +08:00
|
|
|
const TALKING_INDICATORS_MAX = 8;
|
2019-11-02 03:29:33 +08:00
|
|
|
|
|
|
|
const TalkingIndicatorContainer = (props) => {
|
2022-12-09 04:18:17 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
|
|
|
|
2019-11-02 03:29:33 +08:00
|
|
|
if (!enableTalkingIndicator) return null;
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-09-11 04:48:52 +08:00
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
2021-05-19 22:51:31 +08:00
|
|
|
const { sidebarContentPanel } = sidebarContent;
|
2021-09-11 04:48:52 +08:00
|
|
|
const sidebarNavigation = layoutSelectInput((i) => i.sidebarNavigation);
|
2021-09-10 21:16:44 +08:00
|
|
|
const { sidebarNavPanel } = sidebarNavigation;
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
return (
|
|
|
|
<TalkingIndicator
|
|
|
|
{...{
|
|
|
|
sidebarNavPanel,
|
|
|
|
sidebarContentPanel,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2022-12-08 03:47:31 +08:00
|
|
|
users: users[Auth.meetingID],
|
2021-05-18 04:25:07 +08:00
|
|
|
...props,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2019-11-02 03:29:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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 }, {
|
2019-11-02 03:29:33 +08:00
|
|
|
fields: {
|
|
|
|
callerName: 1,
|
|
|
|
talking: 1,
|
2022-04-18 21:38:52 +08:00
|
|
|
floor: 1,
|
2019-11-06 01:10:59 +08:00
|
|
|
color: 1,
|
|
|
|
startTime: 1,
|
2019-11-14 01:56:26 +08:00
|
|
|
muted: 1,
|
2019-11-27 00:44:58 +08:00
|
|
|
intId: 1,
|
2019-11-02 03:29:33 +08:00
|
|
|
},
|
2021-10-08 22:13:37 +08:00
|
|
|
sort: {
|
2021-10-11 21:28:36 +08:00
|
|
|
startTime: 1,
|
2021-10-08 22:13:37 +08:00
|
|
|
},
|
|
|
|
limit: TALKING_INDICATORS_MAX + 1,
|
|
|
|
}).fetch();
|
2019-11-02 03:29:33 +08:00
|
|
|
|
|
|
|
if (usersTalking) {
|
2021-10-08 22:57:26 +08:00
|
|
|
const maxNumberVoiceUsersNotification = usersTalking.length < TALKING_INDICATORS_MAX
|
2021-10-08 03:00:39 +08:00
|
|
|
? usersTalking.length
|
|
|
|
: TALKING_INDICATORS_MAX;
|
|
|
|
|
2021-10-08 22:57:26 +08:00
|
|
|
for (let i = 0; i < maxNumberVoiceUsersNotification; i += 1) {
|
2019-11-14 01:56:26 +08:00
|
|
|
const {
|
2022-04-18 21:38:52 +08:00
|
|
|
callerName, talking, floor, color, muted, intId,
|
2019-11-14 01:56:26 +08:00
|
|
|
} = usersTalking[i];
|
2019-11-15 02:47:27 +08:00
|
|
|
|
2019-11-27 00:44:58 +08:00
|
|
|
talkers[`${intId}`] = {
|
2019-11-06 01:10:59 +08:00
|
|
|
color,
|
2022-04-14 21:59:54 +08:00
|
|
|
transcribing: SpeechService.hasSpeechLocale(intId),
|
2022-04-18 21:38:52 +08:00
|
|
|
floor,
|
2019-11-06 01:10:59 +08:00
|
|
|
talking,
|
2019-11-14 01:56:26 +08:00
|
|
|
muted,
|
2020-11-20 10:11:39 +08:00
|
|
|
callerName,
|
2019-11-06 01:10:59 +08:00
|
|
|
};
|
2019-11-06 04:19:50 +08:00
|
|
|
}
|
2019-11-02 03:29:33 +08:00
|
|
|
}
|
|
|
|
|
2023-08-10 00:12:29 +08:00
|
|
|
const muteUser = debounce((id) => {
|
2021-10-22 20:13:33 +08:00
|
|
|
const user = VoiceUsers.findOne({ meetingId, intId: id }, {
|
2019-11-14 01:56:26 +08:00
|
|
|
fields: {
|
|
|
|
muted: 1,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (user.muted) return;
|
|
|
|
makeCall('toggleVoice', id);
|
2023-08-10 00:12:29 +08:00
|
|
|
}, TALKING_INDICATOR_MUTE_INTERVAL, { leading: true, trailing: false });
|
2019-11-14 01:56:26 +08:00
|
|
|
|
2019-11-02 03:29:33 +08:00
|
|
|
return {
|
|
|
|
talkers,
|
2021-01-26 09:01:26 +08:00
|
|
|
muteUser,
|
2020-11-20 03:12:05 +08:00
|
|
|
isBreakoutRoom: meetingIsBreakout(),
|
2021-10-08 03:00:39 +08:00
|
|
|
moreThanMaxIndicators: usersTalking.length > TALKING_INDICATORS_MAX,
|
2019-11-02 03:29:33 +08:00
|
|
|
};
|
|
|
|
})(TalkingIndicatorContainer);
|