From 64f1e107a4a6de9b6add149f05598f74f2d558e5 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Thu, 5 Jan 2017 07:20:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- src/css/izi/components.css | 7 +++++++ src/recent-torrents.js | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 41a0d7d..25ee3da 100644 --- a/index.js +++ b/index.js @@ -339,4 +339,4 @@ client.on('complete', function (metadata, infohash, rinfo) { // spider.on('nodes', (nodes)=>console.log('foundNodes')) -spider.listen(4445) \ No newline at end of file +//spider.listen(4445) \ No newline at end of file diff --git a/src/css/izi/components.css b/src/css/izi/components.css index 809499f..24633a8 100644 --- a/src/css/izi/components.css +++ b/src/css/izi/components.css @@ -13,3 +13,10 @@ width: 100%; } } + +@media only screen and (max-width: 445px) +{ + .recent-title { + padding-left: 10px !important; + } +} diff --git a/src/recent-torrents.js b/src/recent-torrents.js index e29f135..f9fd8c5 100644 --- a/src/recent-torrents.js +++ b/src/recent-torrents.js @@ -5,6 +5,7 @@ import {List, ListItem} from 'material-ui/List'; import Subheader from 'material-ui/Subheader'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; +import FlatButton from 'material-ui/FlatButton'; const TorrentLine = (props) => { const torrent = props.torrent; @@ -146,6 +147,8 @@ export default class RecentTorrents extends Component { constructor() { super() this.torrents = []; + this.displayQueue = []; + this.state = { pause: false } } componentDidMount() { window.torrentSocket.emit('recentTorrents', (data) => { @@ -153,18 +156,38 @@ export default class RecentTorrents extends Component { this.torrents = data; this.forceUpdate(); } + + this.displayNewTorrent = setInterval(() => { + if(this.displayQueue.length == 0) + return; + + if(this.state.pause) + return; + + let torrent = this.displayQueue.shift(); + this.torrents.unshift(torrent); + if(this.torrents.length > 10) + this.torrents.pop() + + this.forceUpdate(); + }, 850); }); this.newTorrentFunc = (torrent) => { - this.torrents.unshift(torrent); - if(this.torrents.length > 10) - this.torrents.pop() + this.displayQueue.push(torrent); this.forceUpdate(); }; window.torrentSocket.on('newTorrent', this.newTorrentFunc); } + pauseAndContinue() { + this.setState({ + pause: !this.state.pause + }); + } componentWillUnmount() { if(this.newTorrentFunc) window.torrentSocket.off('newTorrent', this.newTorrentFunc); + if(this.displayNewTorrent) + clearInterval(this.displayNewTorrent); } render() { if(!this.torrents || this.torrents.length == 0) @@ -172,7 +195,12 @@ export default class RecentTorrents extends Component { return ( - Most recent torrents + + { + this.pauseAndContinue() + }} /> + Most recent torrents{this.displayQueue.length > 0 ? ` (and ${this.displayQueue.length} more)` : null} + { this.torrents.map((torrent, index) =>{