Add missing PropTypes
parent
35b3da155d
commit
0561ff64ac
|
|
@ -248,10 +248,10 @@ export default class RoomClient
|
||||||
logger.error('getFileHistory() | failed: %o', error);
|
logger.error('getFileHistory() | failed: %o', error);
|
||||||
|
|
||||||
this._dispatch(requestActions.notify({
|
this._dispatch(requestActions.notify({
|
||||||
type: 'error',
|
type : 'error',
|
||||||
text: 'Could not get file history'
|
text : 'Could not get file history'
|
||||||
}));
|
}));
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
muteMic()
|
muteMic()
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import React, { Component, Fragment } from 'react';
|
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 magnet from 'magnet-uri';
|
||||||
import * as requestActions from '../../redux/requestActions';
|
import * as requestActions from '../../redux/requestActions';
|
||||||
import { saveAs } from 'file-saver/FileSaver';
|
import { saveAs } from 'file-saver/FileSaver';
|
||||||
import { client } from './index';
|
import { client } from './index';
|
||||||
|
|
||||||
const DEFAULT_PICTURE = 'resources/images/avatar-empty.jpeg';
|
const DEFAULT_PICTURE = 'resources/images/avatar-empty.jpeg';
|
||||||
|
|
||||||
|
|
@ -71,13 +72,13 @@ class FileEntry extends Component
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
download = () =>
|
handleDownload = () =>
|
||||||
{
|
{
|
||||||
this.setState({
|
this.setState({
|
||||||
active : true
|
active : true
|
||||||
});
|
});
|
||||||
|
|
||||||
const magnet = this.props.data.file.magnet;
|
const magnetURI = this.props.data.file.magnet;
|
||||||
|
|
||||||
const existingTorrent = client.get(magnet);
|
const existingTorrent = client.get(magnet);
|
||||||
|
|
||||||
|
|
@ -87,7 +88,7 @@ class FileEntry extends Component
|
||||||
return this.handleTorrent(existingTorrent);
|
return this.handleTorrent(existingTorrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.add(magnet, this.handleTorrent);
|
client.add(magnetURI, this.handleTorrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
render()
|
render()
|
||||||
|
|
@ -105,7 +106,7 @@ class FileEntry extends Component
|
||||||
|
|
||||||
{!this.state.active && !this.state.files && (
|
{!this.state.active && !this.state.files && (
|
||||||
<div className='file-info'>
|
<div className='file-info'>
|
||||||
<span className='button' onClick={this.download}>
|
<span className='button' onClick={this.handleDownload}>
|
||||||
<img src='resources/images/download-icon.svg' />
|
<img src='resources/images/download-icon.svg' />
|
||||||
</span>
|
</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 = {
|
const mapDispatchToProps = {
|
||||||
notify : requestActions.notify
|
notify : requestActions.notify
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import WebTorrent from 'webtorrent';
|
import WebTorrent from 'webtorrent';
|
||||||
import createTorrent from 'create-torrent';
|
import createTorrent from 'create-torrent';
|
||||||
|
|
@ -8,7 +9,7 @@ import * as stateActions from '../../redux/stateActions';
|
||||||
import * as requestActions from '../../redux/requestActions';
|
import * as requestActions from '../../redux/requestActions';
|
||||||
import { store } from '../../store';
|
import { store } from '../../store';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import FileEntry from './FileEntry';
|
import FileEntry, { FileEntryProps } from './FileEntry';
|
||||||
|
|
||||||
export const client = new WebTorrent({
|
export const client = new WebTorrent({
|
||||||
tracker : {
|
tracker : {
|
||||||
|
|
@ -130,6 +131,10 @@ class FileSharing extends Component
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSharing.propTypes = {
|
||||||
|
sharing : PropTypes.arrayOf(FileEntryProps.data).isRequired
|
||||||
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state) =>
|
const mapStateToProps = (state) =>
|
||||||
({
|
({
|
||||||
sharing : state.sharing
|
sharing : state.sharing
|
||||||
|
|
|
||||||
|
|
@ -452,8 +452,8 @@ export const addFile = (payload) =>
|
||||||
export const addFileHistory = (fileHistory) =>
|
export const addFileHistory = (fileHistory) =>
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
type: 'ADD_FILE_HISTORY',
|
type : 'ADD_FILE_HISTORY',
|
||||||
payload: { fileHistory }
|
payload : { fileHistory }
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ class Room extends EventEmitter
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
protooPeer.send('file-history-receive', {
|
protooPeer.send('file-history-receive', {
|
||||||
fileHistory: this._fileHistory
|
fileHistory : this._fileHistory
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue