2017-09-20 01:47:57 +08:00
|
|
|
import React from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2017-09-26 04:28:36 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2018-11-01 23:03:16 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2018-11-15 02:04:23 +08:00
|
|
|
import Users from '/imports/api/users/';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-09-20 01:47:57 +08:00
|
|
|
import AudioControls from './component';
|
2017-09-29 21:38:10 +08:00
|
|
|
import AudioModalContainer from '../audio-modal/container';
|
2017-09-20 01:47:57 +08:00
|
|
|
import Service from '../service';
|
|
|
|
|
2017-09-26 04:28:36 +08:00
|
|
|
const AudioControlsContainer = props => <AudioControls {...props} />;
|
2017-09-20 01:47:57 +08:00
|
|
|
|
2018-11-01 23:03:16 +08:00
|
|
|
const processToggleMuteFromOutside = (e) => {
|
2018-11-14 01:14:30 +08:00
|
|
|
switch (e.data) {
|
|
|
|
case 'c_mute': {
|
|
|
|
makeCall('toggleSelfVoice');
|
|
|
|
break;
|
|
|
|
}
|
2018-11-21 21:46:13 +08:00
|
|
|
case 'get_audio_joined_status': {
|
|
|
|
const audioJoinedState = AudioManager.isConnected ? 'joinedAudio' : 'notInAudio';
|
|
|
|
this.window.parent.postMessage({ response: audioJoinedState }, '*');
|
|
|
|
break;
|
|
|
|
}
|
2018-11-14 01:14:30 +08:00
|
|
|
case 'c_mute_status': {
|
|
|
|
const muteState = AudioManager.isMuted ? 'selfMuted' : 'selfUnmuted';
|
|
|
|
this.window.parent.postMessage({ response: muteState }, '*');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
// console.log(e.data);
|
|
|
|
}
|
2018-11-01 23:03:16 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
export default withModalMounter(withTracker(({ mountModal }) =>
|
|
|
|
({
|
2018-11-01 23:03:16 +08:00
|
|
|
processToggleMuteFromOutside: arg => processToggleMuteFromOutside(arg),
|
2018-01-08 12:44:42 +08:00
|
|
|
mute: Service.isConnected() && !Service.isListenOnly() && !Service.isEchoTest(),
|
|
|
|
unmute: Service.isConnected() && !Service.isListenOnly() && Service.isMuted(),
|
|
|
|
join: Service.isConnected() && !Service.isEchoTest(),
|
|
|
|
disable: Service.isConnecting() || Service.isHangingUp(),
|
|
|
|
glow: Service.isTalking() && !Service.isMuted(),
|
|
|
|
handleToggleMuteMicrophone: () => Service.toggleMuteMicrophone(),
|
2018-11-15 02:04:23 +08:00
|
|
|
handleJoinAudio: () => {
|
2018-11-20 02:59:47 +08:00
|
|
|
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
|
2018-11-15 02:04:23 +08:00
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
2018-11-21 20:59:30 +08:00
|
|
|
const micsLocked = (currentUser.locked && meeting.lockSettingsProp.disableMic);
|
2018-11-15 02:04:23 +08:00
|
|
|
|
2018-11-20 02:59:47 +08:00
|
|
|
return micsLocked ? Service.joinListenOnly() : mountModal(<AudioModalContainer />);
|
2018-11-15 02:04:23 +08:00
|
|
|
},
|
2018-01-08 12:44:42 +08:00
|
|
|
handleLeaveAudio: () => Service.exitAudio(),
|
|
|
|
}))(AudioControlsContainer));
|