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/';
|
|
|
|
import VideoService from '../service';
|
|
|
|
|
|
|
|
const baseName = Meteor.settings.public.app.basename;
|
2017-12-09 00:38:51 +08:00
|
|
|
|
|
|
|
const isSharingVideo = () => {
|
|
|
|
const userId = Auth.userID;
|
2018-03-15 20:58:56 +08:00
|
|
|
const user = Users.findOne({ userId });
|
|
|
|
return !!user.has_stream;
|
2017-12-09 00:38:51 +08:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2018-03-21 15:27:06 +08:00
|
|
|
const isConnecting = (!isSharingVideo && isConnected);
|
2018-04-03 19:40:33 +08:00
|
|
|
|
|
|
|
const isLocked = (lockCam && userLocked);
|
2018-03-21 15:27:06 +08:00
|
|
|
|
2018-03-15 20:58:56 +08:00
|
|
|
return isLocked
|
|
|
|
|| isWaitingResponse
|
2018-03-21 15:27:06 +08:00
|
|
|
|| isConnecting
|
2018-03-23 01:02:59 +08:00
|
|
|
|| !videoShareAllowed();
|
2018-03-15 20:58:56 +08:00
|
|
|
};
|
|
|
|
|
2017-12-09 00:38:51 +08:00
|
|
|
export default {
|
2018-03-15 20:58:56 +08:00
|
|
|
isSharingVideo,
|
|
|
|
isDisabled,
|
|
|
|
baseName,
|
2018-03-23 01:02:59 +08:00
|
|
|
videoShareAllowed,
|
2017-12-09 00:38:51 +08:00
|
|
|
};
|