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
This commit is contained in:
Someone
2023-11-01 00:25:56 +00:00
parent 534318f74c
commit 33fa6cfafe
2 changed files with 6 additions and 6 deletions

View File

@@ -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,

View File

@@ -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) {