import React, { Component } from 'react'; import formatBytes from './format-bytes' export default class TorrentsStatistic extends Component { constructor(props) { super(props) this.stats = props.stats || {} } componentDidMount() { this.newTorrentFunc = (torrent) => { this.stats.size += torrent.size; this.stats.torrents++; this.stats.files += torrent.files; this.forceUpdate() } window.torrentSocket.on('newTorrent', this.newTorrentFunc); } componentWillUnmount() { if(this.newTorrentFunc) window.torrentSocket.off('newTorrent', this.newTorrentFunc); } render() { return (
{ formatBytes(this.stats.size, 1) } {__('data')}
{this.stats.torrents} {__('torrents')}
{this.stats.files} {__('files')}
0 ? '#19c632' : 'white', fontSize: '1.15em', fill: window.peers > 0 ? '#19c632' : 'white'}}>
{window.peers} {__('peers')}
0 ? '#19c687' : 'white', fontSize: '1.15em', fill: window.peersTorrents > 0 ? '#19c687' : 'white', marginLeft: '20px'}}>
{window.peersTorrents} {__('remote torrents')}
{ window.p2pStatus == 0 &&
{__('not available')}
} { window.p2pStatus == 1 &&
{__('redirect')}
} { window.p2pStatus == 2 &&
{__('direct')}
}
) } }