From d8ddec16389b2ae70f0b32991aaefc01b949163f Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Fri, 29 Nov 2024 11:16:51 +0200 Subject: [PATCH] fix TB free free active item logic --- addon/moch/torbox.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addon/moch/torbox.js b/addon/moch/torbox.js index 52fbd27..88edbc3 100644 --- a/addon/moch/torbox.js +++ b/addon/moch/torbox.js @@ -151,8 +151,9 @@ async function freeLastActiveTorrent(apiKey) { if (seedingTorrent) { return controlTorrent(apiKey, seedingTorrent.id, 'stop_seeding'); } - if (torrents.filter(statusDownloading).pop()) { - return controlTorrent(apiKey, seedingTorrent.id, 'delete'); + const downloadingTorrent = torrents.filter(statusDownloading).pop(); + if (downloadingTorrent) { + return controlTorrent(apiKey, downloadingTorrent.id, 'delete'); } return Promise.reject({ detail: 'No torrent to pause found' }); }