diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 217e268..f6f4764 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -566,15 +566,7 @@ export default class RoomClient if (existingTorrent) { - const { displayName, picture } = store.getState().settings; - - const file = { - magnetUri : existingTorrent.magnetURI, - displayName, - picture - }; - - return this._sendFile(file); + return this._sendFile(existingTorrent.magnetURI); } this._webTorrent.seed(files, (newTorrent) => @@ -584,34 +576,24 @@ export default class RoomClient text : 'File successfully shared.' })); - const { displayName, picture } = store.getState().settings; - const file = { - magnetUri : newTorrent.magnetURI, - displayName, - picture - }; - store.dispatch(stateActions.addFile( - { - magnetUri : file.magnetUri, - displayName : displayName, - picture : picture, - me : true - })); + this._peerId, + newTorrent.magnetURI + )); - this._sendFile(file); + this._sendFile(newTorrent.magnetURI); }); }); } // { file, name, picture } - async _sendFile(file) + async _sendFile(magnetUri) { - logger.debug('sendFile() [file: %o]', file); + logger.debug('sendFile() [magnetUri: %o]', magnetUri); try { - await this.sendRequest('sendFile', { file }); + await this.sendRequest('sendFile', { magnetUri }); } catch (error) { @@ -1392,9 +1374,9 @@ export default class RoomClient case 'sendFile': { - const { file } = notification.data; + const { peerId, magnetUri } = notification.data; - store.dispatch(stateActions.addFile(file)); + store.dispatch(stateActions.addFile(peerId, magnetUri)); store.dispatch(requestActions.notify( { diff --git a/app/src/actions/stateActions.js b/app/src/actions/stateActions.js index 98f6fda..23639f0 100644 --- a/app/src/actions/stateActions.js +++ b/app/src/actions/stateActions.js @@ -503,11 +503,11 @@ export const dropMessages = () => }; }; -export const addFile = (file) => +export const addFile = (peerId, magnetUri) => { return { type : 'ADD_FILE', - payload : { file } + payload : { peerId, magnetUri } }; }; diff --git a/app/src/components/MeetingDrawer/FileSharing/File.js b/app/src/components/MeetingDrawer/FileSharing/File.js index 05b92b0..72e6fbc 100644 --- a/app/src/components/MeetingDrawer/FileSharing/File.js +++ b/app/src/components/MeetingDrawer/FileSharing/File.js @@ -1,12 +1,12 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; +import * as appPropTypes from '../../appPropTypes'; import { connect } from 'react-redux'; import { withRoomContext } from '../../../RoomContext'; import { withStyles } from '@material-ui/core/styles'; import magnet from 'magnet-uri'; import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; -import EmptyAvatar from '../../../images/avatar-empty.jpeg'; const styles = (theme) => ({ @@ -55,15 +55,18 @@ class File extends React.PureComponent { const { roomClient, + displayName, + picture, canShareFiles, + magnetUri, file, classes } = this.props; return (
- Peer avatar - + Avatar +
{ file.files ? @@ -93,17 +96,13 @@ class File extends React.PureComponent :null } - { file.me ? - 'You shared a file' - : - `${file.displayName} shared a file` - } + { `${displayName} shared a file` } { !file.active && !file.files ?
- {magnet.decode(file.magnetUri).dn} + { magnet.decode(magnetUri).dn } { canShareFiles ?