From 7c7780b17ecbb9d81d37fd75daca7a9e638c0116 Mon Sep 17 00:00:00 2001 From: Mathias Rasmussen Date: Thu, 26 May 2016 20:26:25 +0200 Subject: [PATCH] Adding duplicate torrent when stopped --- renderer/main.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/renderer/main.js b/renderer/main.js index bf762730..f91567c3 100644 --- a/renderer/main.js +++ b/renderer/main.js @@ -878,12 +878,21 @@ function torrentInfoHash (torrentKey, infoHash) { torrentSummary ? 'existing' : 'new', torrentKey) if (!torrentSummary) { - torrentSummary = { - torrentKey: torrentKey, - status: 'new' + // Check if another torrent has the same infoHash + var duplicate = state.saved.torrents.find((x) => x.infoHash === infoHash) + + if (duplicate) { + duplicate.torrentKey = torrentKey + duplicate.status = 'new' + sound.play('ENABLE') + } else { + torrentSummary = { + torrentKey: torrentKey, + status: 'new' + } + state.saved.torrents.unshift(torrentSummary) + sound.play('ADD') } - state.saved.torrents.unshift(torrentSummary) - sound.play('ADD') } torrentSummary.infoHash = infoHash