From 33fa6cfafe435184048e165ca8b0472bb864da38 Mon Sep 17 00:00:00 2001 From: Someone <10882916+InterN0te@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:25:56 +0000 Subject: [PATCH] Fixed torrent upload speed comparison to consider it active Torrent.uploadSpeed is already in Bytes/s, no need to multiple SpeedLimitOfActiveTorrents by 8 See PR #1273 and Issue #488 --- src/widgets/torrent/TorrentTile.spec.ts | 8 ++++---- src/widgets/torrent/TorrentTile.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widgets/torrent/TorrentTile.spec.ts b/src/widgets/torrent/TorrentTile.spec.ts index 49fde4e9b..a3c1edf0f 100644 --- a/src/widgets/torrent/TorrentTile.spec.ts +++ b/src/widgets/torrent/TorrentTile.spec.ts @@ -138,8 +138,8 @@ describe('TorrentTile', () => { }; const torrents: NormalizedTorrent[] = [ constructTorrent('ABC', 'Nice Torrent', false, 672, 672), - constructTorrent('HH', 'I am completed and uploading less than 10 ko/s (81919 = 9.99ko/s)', true, 0, 81919), - constructTorrent('HH', 'I am completed and uploading more than 10 ko/s (81921 = 10.01ko/s)', true, 0, 81921), + constructTorrent('HH', 'I am completed and uploading less than 10 ko/s (10239 ≈ 9.99ko/s)', true, 0, 10239), + constructTorrent('HH', 'I am completed and uploading more than 10 ko/s (10241 ≈ 10.01ko/s)', true, 0, 10241), constructTorrent('HH', 'I am completed', true, 0, 0), constructTorrent('HH', 'I am stale', false, 0, 0), ]; @@ -235,8 +235,8 @@ const constructTorrent = ( id: string, name: string, isCompleted: boolean, - downloadSpeed: number, - uploadSpeed: number, + downloadSpeed: number, // Bytes per second in @ctrl/shared-torrent + uploadSpeed: number, // Bytes per second in @ctrl/shared-torrent label?: string ): NormalizedTorrent => ({ id, diff --git a/src/widgets/torrent/TorrentTile.tsx b/src/widgets/torrent/TorrentTile.tsx index 47fa4844a..ee4d0cea0 100644 --- a/src/widgets/torrent/TorrentTile.tsx +++ b/src/widgets/torrent/TorrentTile.tsx @@ -44,7 +44,7 @@ const definition = defineWidget({ type: 'switch', defaultValue: true, }, - SpeedLimitOfActiveTorrents: { // Unit : ko/s + SpeedLimitOfActiveTorrents: { // Unit : kB/s type: 'number', defaultValue: 10, }, @@ -202,7 +202,7 @@ function TorrentTile({ widget }: TorrentTileProps) { export const filterTorrents = (widget: ITorrent, torrents: NormalizedTorrent[]) => { let result = torrents; if (!widget.properties.displayCompletedTorrents) { - result = result.filter((torrent) => !torrent.isCompleted || (widget.properties.displayActiveTorrents && torrent.uploadSpeed > widget.properties.SpeedLimitOfActiveTorrents * 1024 * 8)); + result = result.filter((torrent) => !torrent.isCompleted || (widget.properties.displayActiveTorrents && torrent.uploadSpeed > widget.properties.SpeedLimitOfActiveTorrents * 1024)); } if (widget.properties.labelFilter.length > 0) {