fix(p2p): fix disconnects after each call

This commit is contained in:
Alexey Kasyanchuk
2018-02-17 19:50:32 +03:00
parent 91f5a3fabd
commit 98f0404869
2 changed files with 29 additions and 6 deletions

View File

@ -133,6 +133,7 @@ export default class Search extends Component {
window.torrentSocket.emit('searchFiles', oldSearch ? this.currentSearch : this.searchValue, searchFilesParams, window.customLoader((torrents) => {
if(torrents) {
console.log('back torrents')
this.searchFiles = torrents;
let files = 0;
torrents.forEach((torrent) => {
@ -166,6 +167,7 @@ export default class Search extends Component {
orderDesc: this.state.orderDesc,
}, window.customLoader((torrents) => {
if(torrents) {
console.log('back torrents')
this.searchTorrents = this.searchTorrents.concat(torrents);
if(torrents.length != this.searchLimit)
this.moreSearchTorrents = false;
@ -213,12 +215,20 @@ export default class Search extends Component {
};
window.torrentSocket.emit('statistic', window.customLoader(this.newStatisticFunc));
window.torrentSocket.on('newStatistic', this.newStatisticFunc);
this.remoteSearchTorrent = (torrents) => {
console.log(torrents)
}
window.torrentSocket.on('remoteSearchTorrent', this.remoteSearchTorrent);
}
componentWillUnmount()
{
if(this.newStatisticFunc)
window.torrentSocket.off('newStatistic', this.newStatisticFunc);
if(this.remoteSearchTorrent)
window.torrentSocket.off('remoteSearchTorrent', this.remoteSearchTorrent);
session = {
searchTorrents: this.searchTorrents,
searchFiles: this.searchFiles,