feat(p2p): files search also

This commit is contained in:
Alexey Kasyanchuk
2018-02-17 20:04:54 +03:00
parent 98f0404869
commit c33f927a7d
4 changed files with 32 additions and 7 deletions

View File

@ -17,6 +17,8 @@ import MenuItem from 'material-ui/MenuItem';
import formatBytes from './format-bytes'
import _ from 'lodash'
let session;
class TorrentsStatistic extends Component {
@ -217,9 +219,16 @@ export default class Search extends Component {
window.torrentSocket.on('newStatistic', this.newStatisticFunc);
this.remoteSearchTorrent = (torrents) => {
console.log(torrents)
this.searchTorrents = _.unionBy(this.searchTorrents, torrents, 'hash')
this.forceUpdate();
}
window.torrentSocket.on('remoteSearchTorrent', this.remoteSearchTorrent);
this.remoteSearchFiles = (torrents) => {
this.searchFiles = _.unionBy(this.searchFiles, torrents, 'hash')
this.forceUpdate();
}
window.torrentSocket.on('remoteSearchFiles', this.remoteSearchFiles);
}
componentWillUnmount()
{
@ -229,6 +238,9 @@ export default class Search extends Component {
if(this.remoteSearchTorrent)
window.torrentSocket.off('remoteSearchTorrent', this.remoteSearchTorrent);
if(this.remoteSearchFiles)
window.torrentSocket.off('remoteSearchFiles', this.remoteSearchFiles);
session = {
searchTorrents: this.searchTorrents,
searchFiles: this.searchFiles,