fix(search): merge files in search when same torrent twice in a row
This commit is contained in:
@ -204,10 +204,33 @@ export default class Search extends Component {
|
|||||||
if(files != this.searchLimit)
|
if(files != this.searchLimit)
|
||||||
this.moreSearchFiles = false;
|
this.moreSearchFiles = false;
|
||||||
|
|
||||||
|
this.mergeFiles()
|
||||||
|
|
||||||
this.setState({moreFilesIndicator: false});
|
this.setState({moreFilesIndicator: false});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
mergeFiles()
|
||||||
|
{
|
||||||
|
for(let i = 0; i < this.searchFiles.length; i++)
|
||||||
|
{
|
||||||
|
for(let j = i + 1; j < this.searchFiles.length; j++)
|
||||||
|
{
|
||||||
|
if(this.searchFiles[i].hash != this.searchFiles[j].hash)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if(!this.searchFiles[i].remove)
|
||||||
|
{
|
||||||
|
this.searchFiles[i].path = this.searchFiles[i].path.concat(this.searchFiles[j].path)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchFiles[j].remove = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchFiles = this.searchFiles.filter(torrent => !torrent.remove)
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.newStatisticFunc = (statistic) => {
|
this.newStatisticFunc = (statistic) => {
|
||||||
if(statistic) {
|
if(statistic) {
|
||||||
@ -230,6 +253,7 @@ export default class Search extends Component {
|
|||||||
if(!torrents)
|
if(!torrents)
|
||||||
return
|
return
|
||||||
this.searchFiles = _.unionBy(this.searchFiles, torrents, 'hash')
|
this.searchFiles = _.unionBy(this.searchFiles, torrents, 'hash')
|
||||||
|
this.mergeFiles()
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
window.torrentSocket.on('remoteSearchFiles', this.remoteSearchFiles);
|
window.torrentSocket.on('remoteSearchFiles', this.remoteSearchFiles);
|
||||||
|
Reference in New Issue
Block a user