import React, { Component } from 'react'; import { connect } from 'react-redux'; import selectTorrent, { UNION, SUBTRACT, EXCLUSIVE } from '../actions/selection'; import { formatBitrate } from '../bitrate'; import Ratio from './ratio'; import TorrentProgress from './torrent_progress'; const name_style = { maxWidth: `${window.innerWidth * 0.25}px`, textOverflow: 'ellipsis', overflowX: 'hidden', whiteSpace: 'nowrap' }; class _Torrent extends Component { shouldComponentUpdate(nextProps, _) { const { selection, torrent } = this.props; const nt = nextProps.torrent; const active = selection.indexOf(torrent.id); const nActive = nextProps.selection.indexOf(torrent.id); return active !== nActive || torrent.id !== nt.id || torrent.status !== nt.status || torrent.rate_down !== nt.rate_down || torrent.rate_up !== nt.rate_up; } render() { const { dispatch, selection, torrent } = this.props; const t = torrent; return (
{ if (selection.length > 0) { dispatch(selectTorrent([], EXCLUSIVE)); } else { dispatch(selectTorrent(Object.keys(torrents), EXCLUSIVE)); } }} /> | name | up | down | ratio | progress |
---|