perf(top): less cpu usage on top page update

This commit is contained in:
Alexey Kasyanchuk 2018-04-10 16:55:11 +03:00
parent 5ae597f35a
commit fce7fe4369

View File

@ -42,11 +42,20 @@ export default class TopPage extends Page {
if(data && data.length > 0)
{
this.topTorrents[type] = this.topTorrents[type].concat(data);
this.forceUpdate()
this._update()
}
})
)
}
_update()
{
if(this.timeForce)
return
this.timeForce = setTimeout(() => {
delete this.timeForce
this.forceUpdate()
}, 550)
}
componentDidMount()
{
super.componentDidMount();
@ -59,7 +68,7 @@ export default class TopPage extends Page {
return
type = type ? type : 'main'
this.topTorrents[type] = _.orderBy(_.unionBy(this.topTorrents[type], torrents, 'hash'), ['seeders'], ['desc'])
this.forceUpdate();
this._update();
}
window.torrentSocket.on('remoteTopTorrents', this.remoteTopTorrents);
}