bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/video-provider/video-menu/service.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-15 20:58:56 +08:00
import Settings from '/imports/ui/services/settings';
import mapUser from '/imports/ui/services/user/mapUser';
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users/';
2018-04-10 02:48:21 +08:00
import MediaService from '/imports/ui/components/media/service';
2018-03-15 20:58:56 +08:00
import VideoService from '../service';
const baseName = Meteor.settings.public.app.basename;
const isSharingVideo = () => {
const userId = Auth.userID;
2018-03-15 20:58:56 +08:00
const user = Users.findOne({ userId });
return !!user.has_stream;
};
2018-03-23 01:02:59 +08:00
const videoShareAllowed = () => Settings.dataSaving.viewParticipantsWebcams;
2018-03-15 20:58:56 +08:00
const isDisabled = () => {
const isWaitingResponse = VideoService.isWaitingResponse();
const isConnected = VideoService.isConnected();
2018-03-27 02:26:52 +08:00
const lockCam = VideoService.isLocked();
2018-03-15 20:58:56 +08:00
const user = Users.findOne({ userId: Auth.userID });
const userLocked = mapUser(user).isLocked;
const isConnecting = (!isSharingVideo && isConnected);
const isLocked = (lockCam && userLocked);
2018-03-15 20:58:56 +08:00
return isLocked
|| isWaitingResponse
|| isConnecting
2018-03-23 01:02:59 +08:00
|| !videoShareAllowed();
2018-03-15 20:58:56 +08:00
};
export default {
2018-03-15 20:58:56 +08:00
isSharingVideo,
isDisabled,
baseName,
2018-04-10 02:48:21 +08:00
toggleSwapLayout: MediaService.toggleSwapLayout,
swapLayoutAllowed: MediaService.shouldEnableSwapLayout,
2018-03-23 01:02:59 +08:00
videoShareAllowed,
};