From e215e7d70e66dd4dc2053ba41eb702200b9d7419 Mon Sep 17 00:00:00 2001 From: AdamWHY2K Date: Sat, 28 Jun 2025 22:23:02 +0100 Subject: [PATCH] Enhancement: sort qBittorrent leechProgress (#5456) --- src/widgets/qbittorrent/component.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/widgets/qbittorrent/component.jsx b/src/widgets/qbittorrent/component.jsx index c9f648165..bd201fd51 100644 --- a/src/widgets/qbittorrent/component.jsx +++ b/src/widgets/qbittorrent/component.jsx @@ -45,6 +45,25 @@ export default function Component({ service }) { } const leech = torrentData.length - completed; + const statePriority = [ + "downloading", + "forcedDL", + "metaDL", + "forcedMetaDL", + "checkingDL", + "stalledDL", + "queuedDL", + "pausedDL", + ]; + + leechTorrents.sort((firstTorrent, secondTorrent) => { + const firstStateIndex = statePriority.indexOf(firstTorrent.state); + const secondStateIndex = statePriority.indexOf(secondTorrent.state); + if (firstStateIndex !== secondStateIndex) { + return firstStateIndex - secondStateIndex; + } + return secondTorrent.progress - firstTorrent.progress; + }); return ( <>