bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/nav-bar/service.js

61 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-01-04 02:14:35 +08:00
import Auth from '/imports/ui/services/auth';
import Breakouts from '/imports/api/breakouts';
2019-01-04 02:14:35 +08:00
import { makeCall } from '/imports/ui/services/api';
import Meetings from '/imports/api/meetings';
import fp from 'lodash/fp';
const getBreakoutByUserId = userId => Breakouts.find({ 'users.userId': userId }).fetch();
const getBreakoutByUser = user => Breakouts.findOne({ users: user });
const getUsersFromBreakouts = breakoutsArray => breakoutsArray
.map(breakout => breakout.users)
.reduce((acc, usersArray) => [...acc, usersArray], []);
const filterUserURLs = userId => breakoutUsersArray => breakoutUsersArray
.filter(user => user.userId === userId);
const getLastURLInserted = breakoutURLArray => breakoutURLArray
.sort((a, b) => a.insertedTime - b.insertedTime).pop();
const getBreakoutUserByUserId = userId => fp.pipe(
getBreakoutByUserId,
getUsersFromBreakouts,
filterUserURLs(userId),
getLastURLInserted,
)(userId);
2018-07-09 20:13:11 +08:00
const getBreakouts = () => Breakouts.find({}, { sort: { sequence: 1 } }).fetch();
2019-01-04 02:14:35 +08:00
const processOutsideToggleRecording = (e) => {
switch (e.data) {
case 'c_record': {
makeCall('toggleRecording');
break;
}
case 'c_recording_status': {
const recordingState = Meetings.findOne({ meetingId: Auth.meetingID }).recordProp.recording;
const recordingMessage = recordingState ? 'recordingStarted' : 'recordingStopped';
this.window.parent.postMessage({ response: recordingMessage }, '*');
break;
}
default: {
// console.log(e.data);
}
}
};
const connectRecordingObserver = () => {
// notify on load complete
this.window.parent.postMessage({ response: 'readyToConnect' }, '*');
};
export default {
2019-01-04 02:14:35 +08:00
connectRecordingObserver: () => connectRecordingObserver(),
processOutsideToggleRecording: arg => processOutsideToggleRecording(arg),
getBreakoutUserByUserId,
getBreakoutByUser,
getBreakouts,
};