2017-08-04 20:24:57 +08:00
|
|
|
import React from 'react';
|
2017-03-28 04:40:44 +08:00
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
2017-05-02 03:52:57 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2017-08-04 20:24:57 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-02 03:52:57 +08:00
|
|
|
import Service from './service';
|
2017-03-28 04:40:44 +08:00
|
|
|
import Audio from './component';
|
2017-05-02 03:52:57 +08:00
|
|
|
import AudioModal from './audio-modal/component';
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-08-04 20:24:57 +08:00
|
|
|
const propTypes = {
|
|
|
|
children: PropTypes.element,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
children: null,
|
|
|
|
};
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-08-04 20:24:57 +08:00
|
|
|
const AudioContainer = props =>
|
|
|
|
(<Audio {...props}>
|
|
|
|
{props.children}
|
|
|
|
</Audio>
|
|
|
|
);
|
2017-05-04 05:39:07 +08:00
|
|
|
|
2017-08-05 04:33:25 +08:00
|
|
|
let didMountedAutoJoin = false;
|
|
|
|
|
2017-05-02 03:52:57 +08:00
|
|
|
export default withModalMounter(createContainer(({ mountModal }) => {
|
2017-04-20 04:42:48 +08:00
|
|
|
const APP_CONFIG = Meteor.settings.public.app;
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-08-04 20:24:57 +08:00
|
|
|
const { autoJoinAudio } = APP_CONFIG;
|
|
|
|
|
2017-03-28 04:40:44 +08:00
|
|
|
return {
|
2017-05-02 03:52:57 +08:00
|
|
|
init: () => {
|
|
|
|
Service.init();
|
2017-08-05 04:33:25 +08:00
|
|
|
if (!autoJoinAudio || didMountedAutoJoin) return;
|
2017-05-04 05:39:07 +08:00
|
|
|
mountModal(<AudioModal handleJoinListenOnly={Service.joinListenOnly} />);
|
2017-08-05 04:33:25 +08:00
|
|
|
didMountedAutoJoin = true;
|
2017-05-02 03:52:57 +08:00
|
|
|
},
|
2017-03-28 04:40:44 +08:00
|
|
|
};
|
2017-05-02 03:52:57 +08:00
|
|
|
}, AudioContainer));
|
2017-08-04 20:24:57 +08:00
|
|
|
|
|
|
|
AudioContainer.propTypes = propTypes;
|
|
|
|
AudioContainer.defaultProps = defaultProps;
|