From 1504288692d8ae32cb400a7cd547a909b322e40c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 10 Sep 2017 20:50:37 +0900 Subject: [PATCH] Implement tracker list --- src/ui/torrent_details.js | 50 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/ui/torrent_details.js b/src/ui/torrent_details.js index 1c97bf4..ce071f6 100644 --- a/src/ui/torrent_details.js +++ b/src/ui/torrent_details.js @@ -73,7 +73,7 @@ class Torrent extends Component { } render() { - const { dispatch, torrent, files } = this.props; + const { dispatch, torrent, files, trackers } = this.props; const status = s => s[0].toUpperCase() + s.slice(1); if (!torrent || !files) { @@ -175,6 +175,35 @@ class Torrent extends Component { + + + + {trackers.map(tracker => +
+
{(() => { + const a = document.createElement("a"); + a.href = tracker.url; + return a.hostname; + })()} + {/* TODO: wire up this button: */} + +
+
+
URL
+
{tracker.url}
+
Last report
+
{date(moment(tracker.last_report))}
+ {tracker.error &&
Error
} + {tracker.error && +
{tracker.error}
} +
+
+ )} +
+
+
); } @@ -247,10 +276,23 @@ class TorrentDetails extends Component { } render() { - const { torrents, files, selection, dispatch } = this.props; + const { + torrents, + files, + trackers, + peers, + selection, + dispatch + } = this.props; const _files = Object.values(files).reduce((s, f) => ({ ...s, [f.torrent_id]: [...(s[f.torrent_id] || []), f] }), {}); + const _trackers = Object.values(trackers).reduce((s, t) => ({ + ...s, [t.torrent_id]: [...(s[t.torrent_id] || []), t] + }), {}); + const _peers = Object.values(peers).reduce((s, p) => ({ + ...s, [p.torrent_id]: [...(s[p.torrent_id] || []), p] + }), {}); return (
{selection.length > 1 ? this.renderHeader.bind(this)() : null} @@ -258,6 +300,8 @@ class TorrentDetails extends Component { dispatch={dispatch} torrent={torrents[id]} files={_files[id] || []} + trackers={_trackers[id] || []} + peers={_peers[id] || []} />)} {selection.length > 3 ?

@@ -275,6 +319,8 @@ export default connect(state => ({ router: state.router, torrents: state.torrents, files: state.files, + trackers: state.trackers, + peers: state.peers, selection: state.selection, server: state.server }))(TorrentDetails);