diff --git a/src/app/search.js b/src/app/search.js index be15d8c..fc19578 100644 --- a/src/app/search.js +++ b/src/app/search.js @@ -219,12 +219,16 @@ export default class Search extends Component { window.torrentSocket.on('newStatistic', this.newStatisticFunc); this.remoteSearchTorrent = (torrents) => { + if(!torrents) + return this.searchTorrents = _.unionBy(this.searchTorrents, torrents, 'hash') this.forceUpdate(); } window.torrentSocket.on('remoteSearchTorrent', this.remoteSearchTorrent); this.remoteSearchFiles = (torrents) => { + if(!torrents) + return this.searchFiles = _.unionBy(this.searchFiles, torrents, 'hash') this.forceUpdate(); } diff --git a/src/app/torrent.js b/src/app/torrent.js index 090c975..c187e92 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -6,11 +6,11 @@ import Divider from 'material-ui/Divider'; import Spinner24 from './images/spinner_24.gif' import LinearProgress from 'material-ui/LinearProgress'; -const contentIcon = (type, category) => { +const contentIcon = (type, category, fill = 'grey') => { if(category == 'xxx') { return ( - + + @@ -43,7 +43,7 @@ const contentIcon = (type, category) => { ) case 'audio': return ( - + + + + + @@ -124,7 +124,7 @@ const contentIcon = (type, category) => { ) case 'disc': return ( - + + @@ -226,7 +226,7 @@ export default class Torrent extends Component { node.onclick = () => { return false } }}> {torrent.name} @@ -239,7 +239,7 @@ export default class Torrent extends Component { }}>
-
+
{ formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)' } @@ -277,7 +277,7 @@ export default class Torrent extends Component {
} - leftIcon={contentIcon(torrent.contentType, torrent.contentCategory)} + leftIcon={contentIcon(torrent.contentType, torrent.contentCategory, torrent.contentCategory != 'xxx' ? (torrent.peer ? '#6f5ee0' : 'grey') : '#d3d3d3')} rightIcon={
{ @@ -287,7 +287,7 @@ export default class Torrent extends Component { { e.preventDefault(); e.stopPropagation(); @@ -324,7 +324,7 @@ export default class Torrent extends Component { { e.preventDefault(); e.stopPropagation(); @@ -336,7 +336,7 @@ export default class Torrent extends Component { { e.preventDefault(); e.stopPropagation(); diff --git a/src/background/p2p.js b/src/background/p2p.js index b02e816..9a32068 100644 --- a/src/background/p2p.js +++ b/src/background/p2p.js @@ -122,7 +122,7 @@ class p2p { socket.on('message', (message) => { if(message.id && callbacks[message.id]) { - callbacks[message.id](message.data); + callbacks[message.id](message.data, socket); delete callbacks[message.id]; } }); diff --git a/src/background/spider.js b/src/background/spider.js index abf0a8c..f2a039f 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -409,8 +409,14 @@ p2p.listen() recive('searchTorrent', (text, navigation, callback) => { searchTorrentCall(text, navigation, callback) - p2p.emit('searchTorrent', {text, navigation}, (remote) => { + p2p.emit('searchTorrent', {text, navigation}, (remote, socketObject) => { console.log('remote search results', remote && remote.length) + if(remote && remote.length > 0) + { + const { _socket: socket } = socketObject + const peer = { address: socket.remoteAddress, port: socket.remotePort } + remote = remote.map(torrent => Object.assign(torrent, {peer})) + } send('remoteSearchTorrent', remote) }) }); @@ -513,8 +519,14 @@ p2p.listen() recive('searchFiles', (text, navigation, callback) => { searchFilesCall(text, navigation, callback) - p2p.emit('searchFiles', {text, navigation}, (remote) => { + p2p.emit('searchFiles', {text, navigation}, (remote, socketObject) => { console.log('remote search files results', remote && remote.length) + if(remote && remote.length > 0) + { + const { _socket: socket } = socketObject + const peer = { address: socket.remoteAddress, port: socket.remotePort } + remote = remote.map(torrent => Object.assign(torrent, {peer})) + } send('remoteSearchFiles', remote) }) });