import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { withRoomContext } from '../../../RoomContext'; import magnet from 'magnet-uri'; const DEFAULT_PICTURE = 'resources/images/avatar-empty.jpeg'; class File extends Component { render() { const { roomClient, torrentSupport, file } = this.props; return (

You shared a file.

{file.displayName} shared a file.

{ roomClient.handleDownload(file.magnetUri); }} >

Your browser does not support downloading files using WebTorrent.

{magnet.decode(file.magnetUri).dn}

If this process takes a long time, there might not be anyone seeding this torrent. Try asking someone to reupload the file that you want.

File finished downloading.

{file.files.map((sharedFile, i) => (
{ roomClient.saveFile(sharedFile); }} >

{sharedFile.name}

))}
); } } File.propTypes = { roomClient : PropTypes.object.isRequired, torrentSupport : PropTypes.bool.isRequired, file : PropTypes.object.isRequired }; const mapStateToProps = (state, { magnetUri }) => { return { file : state.files[magnetUri], torrentSupport : state.room.torrentSupport }; }; export default withRoomContext(connect( mapStateToProps )(File));