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';
|
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) => {
|
|
|
|
if (e.data === 'c_mute') {
|
|
|
|
const newMuteState = !AudioManager.isMuted;
|
|
|
|
makeCall('toggleSelfVoice')
|
|
|
|
.then(() => {
|
|
|
|
this.window.parent.postMessage({ response: { newMuteState } }, '*');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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(),
|
|
|
|
handleJoinAudio: () => mountModal(<AudioModalContainer />),
|
|
|
|
handleLeaveAudio: () => Service.exitAudio(),
|
|
|
|
}))(AudioControlsContainer));
|