perf(top): fix unnecessary drawing on top page

This commit is contained in:
Alexey Kasyanchuk
2018-08-26 16:22:59 +03:00
parent 1e09243756
commit ff4b98bd1f
7 changed files with 82 additions and 34 deletions

View File

@ -6,7 +6,7 @@ import {List, ListItem} from 'material-ui/List';
import Divider from 'material-ui/Divider';
import Subheader from 'material-ui/Subheader';
import RaisedButton from 'material-ui/RaisedButton';
import LinearProgress from 'material-ui/LinearProgress';
import LinearProgress from './LinearProgress';
import {Tabs, Tab} from 'material-ui/Tabs';
import _ from 'lodash'
@ -150,6 +150,12 @@ export default class TopPage extends Page {
Object.keys(this.times).map((time, index) => {
const {torrents} = this.topTorrents[type][time] || {torrents: undefined};
// dont draw top on other page rather than focused
if(this.state.type !== type || this.state.time !== time)
{
return <Tab buttonStyle={time === this.state.time ? {fontWeight: 'bold'} : undefined} style={{minWidth: 150}} key={index} label={this.times[time]} value={time}></Tab>
}
if(!torrents)
return (
<Tab buttonStyle={time === this.state.time ? {fontWeight: 'bold'} : undefined} style={{minWidth: 150}} key={index} label={this.times[time]} value={time}>