более читабельный вариант
This commit is contained in:
@ -168,6 +168,7 @@ export default class RecentTorrents extends Component {
|
|||||||
this.torrents = [];
|
this.torrents = [];
|
||||||
this.displayQueue = [];
|
this.displayQueue = [];
|
||||||
this.displayQueueAssoc = {};
|
this.displayQueueAssoc = {};
|
||||||
|
this.maxDisplaySize = 1000;
|
||||||
this.state = { pause: false }
|
this.state = { pause: false }
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -187,9 +188,7 @@ export default class RecentTorrents extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let speed = 850 - (((this.displayQueue.length / 100)|0) * 100)
|
const speed = 850;
|
||||||
if(speed < 10)
|
|
||||||
speed = 10;
|
|
||||||
|
|
||||||
if(this.state.pause) {
|
if(this.state.pause) {
|
||||||
setTimeout(this.displayNewTorrent, speed);
|
setTimeout(this.displayNewTorrent, speed);
|
||||||
@ -209,9 +208,11 @@ export default class RecentTorrents extends Component {
|
|||||||
this.displayNewTorrent();
|
this.displayNewTorrent();
|
||||||
});
|
});
|
||||||
this.newTorrentFunc = (torrent) => {
|
this.newTorrentFunc = (torrent) => {
|
||||||
|
if(this.displayQueue.length < this.maxDisplaySize) {
|
||||||
this.displayQueue.push(torrent);
|
this.displayQueue.push(torrent);
|
||||||
this.displayQueueAssoc[torrent.hash] = torrent;
|
this.displayQueueAssoc[torrent.hash] = torrent;
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
window.torrentSocket.on('newTorrent', this.newTorrentFunc);
|
window.torrentSocket.on('newTorrent', this.newTorrentFunc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user