Add missing PropTypes

master
Torjus 2018-07-31 10:14:14 +02:00
parent 35b3da155d
commit 0561ff64ac
5 changed files with 33 additions and 13 deletions

View File

@ -251,7 +251,7 @@ export default class RoomClient
type : 'error',
text : 'Could not get file history'
}));
})
});
}
muteMic()

View File

@ -1,9 +1,10 @@
import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import magnet from 'magnet-uri';
import * as requestActions from '../../redux/requestActions';
import { saveAs } from 'file-saver/FileSaver';
import { client } from './index';
import { client } from './index';
const DEFAULT_PICTURE = 'resources/images/avatar-empty.jpeg';
@ -71,13 +72,13 @@ class FileEntry extends Component
});
};
download = () =>
handleDownload = () =>
{
this.setState({
active : true
});
const magnet = this.props.data.file.magnet;
const magnetURI = this.props.data.file.magnet;
const existingTorrent = client.get(magnet);
@ -87,7 +88,7 @@ class FileEntry extends Component
return this.handleTorrent(existingTorrent);
}
client.add(magnet, this.handleTorrent);
client.add(magnetURI, this.handleTorrent);
}
render()
@ -105,7 +106,7 @@ class FileEntry extends Component
{!this.state.active && !this.state.files && (
<div className='file-info'>
<span className='button' onClick={this.download}>
<span className='button' onClick={this.handleDownload}>
<img src='resources/images/download-icon.svg' />
</span>
@ -144,6 +145,20 @@ class FileEntry extends Component
}
}
export const FileEntryProps = {
data : PropTypes.shape({
name : PropTypes.string.isRequired,
picture : PropTypes.string.isRequired,
file : PropTypes.shape({
magnet : PropTypes.string.isRequired
}).isRequired,
me : PropTypes.bool
}).isRequired,
notify : PropTypes.func.isRequired
};
FileEntry.propTypes = FileEntryProps;
const mapDispatchToProps = {
notify : requestActions.notify
};

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import WebTorrent from 'webtorrent';
import createTorrent from 'create-torrent';
@ -8,7 +9,7 @@ import * as stateActions from '../../redux/stateActions';
import * as requestActions from '../../redux/requestActions';
import { store } from '../../store';
import config from '../../../config';
import FileEntry from './FileEntry';
import FileEntry, { FileEntryProps } from './FileEntry';
export const client = new WebTorrent({
tracker : {
@ -130,6 +131,10 @@ class FileSharing extends Component
}
}
FileSharing.propTypes = {
sharing : PropTypes.arrayOf(FileEntryProps.data).isRequired
};
const mapStateToProps = (state) =>
({
sharing : state.sharing