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:
@@ -138,8 +138,8 @@ describe('TorrentTile', () => {
|
|||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672),
|
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 less than 10 ko/s (10239 ≈ 9.99ko/s)', true, 0, 10239),
|
||||||
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 more than 10 ko/s (10241 ≈ 10.01ko/s)', true, 0, 10241),
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 0),
|
constructTorrent('HH', 'I am completed', true, 0, 0),
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0),
|
constructTorrent('HH', 'I am stale', false, 0, 0),
|
||||||
];
|
];
|
||||||
@@ -235,8 +235,8 @@ const constructTorrent = (
|
|||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
isCompleted: boolean,
|
isCompleted: boolean,
|
||||||
downloadSpeed: number,
|
downloadSpeed: number, // Bytes per second in @ctrl/shared-torrent
|
||||||
uploadSpeed: number,
|
uploadSpeed: number, // Bytes per second in @ctrl/shared-torrent
|
||||||
label?: string
|
label?: string
|
||||||
): NormalizedTorrent => ({
|
): NormalizedTorrent => ({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const definition = defineWidget({
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
},
|
},
|
||||||
SpeedLimitOfActiveTorrents: { // Unit : ko/s
|
SpeedLimitOfActiveTorrents: { // Unit : kB/s
|
||||||
type: 'number',
|
type: 'number',
|
||||||
defaultValue: 10,
|
defaultValue: 10,
|
||||||
},
|
},
|
||||||
@@ -202,7 +202,7 @@ function TorrentTile({ widget }: TorrentTileProps) {
|
|||||||
export const filterTorrents = (widget: ITorrent, torrents: NormalizedTorrent[]) => {
|
export const filterTorrents = (widget: ITorrent, torrents: NormalizedTorrent[]) => {
|
||||||
let result = torrents;
|
let result = torrents;
|
||||||
if (!widget.properties.displayCompletedTorrents) {
|
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) {
|
if (widget.properties.labelFilter.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user