perf(top): less cpu usage on top page update
This commit is contained in:
parent
5ae597f35a
commit
fce7fe4369
@ -42,11 +42,20 @@ export default class TopPage extends Page {
|
|||||||
if(data && data.length > 0)
|
if(data && data.length > 0)
|
||||||
{
|
{
|
||||||
this.topTorrents[type] = this.topTorrents[type].concat(data);
|
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()
|
componentDidMount()
|
||||||
{
|
{
|
||||||
super.componentDidMount();
|
super.componentDidMount();
|
||||||
@ -59,7 +68,7 @@ export default class TopPage extends Page {
|
|||||||
return
|
return
|
||||||
type = type ? type : 'main'
|
type = type ? type : 'main'
|
||||||
this.topTorrents[type] = _.orderBy(_.unionBy(this.topTorrents[type], torrents, 'hash'), ['seeders'], ['desc'])
|
this.topTorrents[type] = _.orderBy(_.unionBy(this.topTorrents[type], torrents, 'hash'), ['seeders'], ['desc'])
|
||||||
this.forceUpdate();
|
this._update();
|
||||||
}
|
}
|
||||||
window.torrentSocket.on('remoteTopTorrents', this.remoteTopTorrents);
|
window.torrentSocket.on('remoteTopTorrents', this.remoteTopTorrents);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user