feat(top): p2p top search

This commit is contained in:
Alexey Kasyanchuk
2018-03-25 18:24:34 +03:00
parent 5c777cb629
commit 960731fb80
2 changed files with 32 additions and 2 deletions

View File

@ -36,6 +36,18 @@ export default class TopPage extends Page {
this.forceUpdate()
}))
}
this.remoteTopTorrents = ({torrents, type}) => {
if(!torrents)
return
this.topTorrents[type] = _.orderBy(_.unionBy(this.topTorrents[type], torrents, 'hash'), ['seeders'], ['desc'])
this.forceUpdate();
}
window.torrentSocket.on('remoteTopTorrents', this.remoteTopTorrents);
}
componentWillUnmount()
{
if(this.remoteTopTorrents)
window.torrentSocket.off('remoteTopTorrents', this.remoteTopTorrents);
}
render() {
return (