fix(feed): keep downloading values seperate
This commit is contained in:
parent
d1d816ed03
commit
7592612a3d
@ -30,10 +30,13 @@ module.exports = async ({
|
|||||||
}, 24 * 60 * 60 * 1000);
|
}, 24 * 60 * 60 * 1000);
|
||||||
|
|
||||||
|
|
||||||
const mergeTorrentsWithDownloads = (torrents) => {
|
const mergeTorrentsWithDownloads = (torrents, copy) => {
|
||||||
if(!torrents)
|
if(!torrents)
|
||||||
return torrents
|
return torrents
|
||||||
|
|
||||||
|
if(copy)
|
||||||
|
torrents = _.cloneDeep(torrents)
|
||||||
|
|
||||||
const mergeTorrent = (torrent) => {
|
const mergeTorrent = (torrent) => {
|
||||||
const id = torrentClientHashMap[torrent.hash]
|
const id = torrentClientHashMap[torrent.hash]
|
||||||
if(id)
|
if(id)
|
||||||
@ -65,10 +68,10 @@ module.exports = async ({
|
|||||||
return torrents
|
return torrents
|
||||||
}
|
}
|
||||||
|
|
||||||
const mergeTorrentsWithDownloadsFn = (Fn) => (...args) => {
|
const mergeTorrentsWithDownloadsFn = (Fn, copy) => (...args) => {
|
||||||
const callback = args[args.length - 1]
|
const callback = args[args.length - 1]
|
||||||
const rest = args.slice(0, -1)
|
const rest = args.slice(0, -1)
|
||||||
Fn(...rest, (data) => callback(mergeTorrentsWithDownloads(data)))
|
Fn(...rest, (data) => callback(mergeTorrentsWithDownloads(data, copy)))
|
||||||
}
|
}
|
||||||
|
|
||||||
recive('recentTorrents', function(callback)
|
recive('recentTorrents', function(callback)
|
||||||
@ -867,7 +870,7 @@ module.exports = async ({
|
|||||||
{
|
{
|
||||||
callback(feed.feed)
|
callback(feed.feed)
|
||||||
}
|
}
|
||||||
recive('feed', mergeTorrentsWithDownloadsFn(feedCall));
|
recive('feed', mergeTorrentsWithDownloadsFn(feedCall, true)); // don't overwrite feed value
|
||||||
|
|
||||||
p2p.on('feed', ({}, callback) => {
|
p2p.on('feed', ({}, callback) => {
|
||||||
feedCall((data) => callback(data))
|
feedCall((data) => callback(data))
|
||||||
|
Loading…
Reference in New Issue
Block a user