import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import classNames from 'classnames'; import { withRoomContext } from '../../../RoomContext'; import FileList from './FileList'; class FileSharing extends Component { constructor(props) { super(props); this._fileInput = React.createRef(); } handleFileChange = async (event) => { if (event.target.files.length > 0) { this.props.roomClient.shareFiles(event.target.files); } }; handleClick = () => { if (this.props.torrentSupport) { // We want to open the file dialog when we click a button // instead of actually rendering the input element itself. this._fileInput.current.click(); } }; render() { const { torrentSupport } = this.props; const buttonDescription = torrentSupport ? 'Share file' : 'File sharing not supported'; return (
{buttonDescription}
); } } FileSharing.propTypes = { roomClient : PropTypes.any.isRequired, torrentSupport : PropTypes.bool.isRequired, tabOpen : PropTypes.bool.isRequired }; const mapStateToProps = (state) => { return { torrentSupport : state.room.torrentSupport, tabOpen : state.toolarea.currentToolTab === 'files' }; }; export default withRoomContext(connect( mapStateToProps )(FileSharing));