feat: support aria2 integration (#2226)
This commit is contained in:
@@ -171,7 +171,8 @@ export default function DownloadClientsWidget({
|
||||
options.showCompletedTorrent &&
|
||||
(upSpeed ?? 0) >= Number(options.activeTorrentThreshold) * 1024) ||
|
||||
progress !== 1)) ||
|
||||
(type === "usenet" && ((progress === 1 && options.showCompletedUsenet) || progress !== 1)),
|
||||
(type === "usenet" && ((progress === 1 && options.showCompletedUsenet) || progress !== 1)) ||
|
||||
(type === "miscellaneous" && ((progress === 1 && options.showCompletedHttp) || progress !== 1)),
|
||||
)
|
||||
//Filter following user quick setting
|
||||
.filter(
|
||||
@@ -189,7 +190,7 @@ export default function DownloadClientsWidget({
|
||||
...item,
|
||||
category: item.category !== undefined && item.category.length > 0 ? item.category : undefined,
|
||||
received,
|
||||
ratio: item.sent !== undefined ? item.sent / received : undefined,
|
||||
ratio: item.sent !== undefined ? item.sent / (received || 1) : undefined,
|
||||
//Only add if permission to use mutations
|
||||
actions: integrationsWithInteractions.includes(pair.integration.id)
|
||||
? {
|
||||
@@ -215,6 +216,7 @@ export default function DownloadClientsWidget({
|
||||
options.filterIsWhitelist,
|
||||
options.showCompletedTorrent,
|
||||
options.showCompletedUsenet,
|
||||
options.showCompletedHttp,
|
||||
quickFilters,
|
||||
],
|
||||
);
|
||||
@@ -232,7 +234,7 @@ export default function DownloadClientsWidget({
|
||||
.filter(
|
||||
({ category }) =>
|
||||
!options.applyFilterToRatio ||
|
||||
data.status.type !== "torrent" ||
|
||||
!data.status.types.includes("torrent") ||
|
||||
options.filterIsWhitelist ===
|
||||
options.categoryFilter.some((filter) =>
|
||||
(Array.isArray(category) ? category : [category]).includes(filter),
|
||||
@@ -258,7 +260,7 @@ export default function DownloadClientsWidget({
|
||||
})
|
||||
.sort(
|
||||
({ status: statusA }, { status: statusB }) =>
|
||||
(statusA?.type.length ?? Infinity) - (statusB?.type.length ?? Infinity),
|
||||
(statusA?.types.length ?? Infinity) - (statusB?.types.length ?? Infinity),
|
||||
),
|
||||
[
|
||||
currentItems,
|
||||
@@ -272,8 +274,10 @@ export default function DownloadClientsWidget({
|
||||
|
||||
//Check existing types between torrents and usenet
|
||||
const integrationTypes: ExtendedDownloadClientItem["type"][] = [];
|
||||
|
||||
if (data.some(({ type }) => type === "torrent")) integrationTypes.push("torrent");
|
||||
if (data.some(({ type }) => type === "usenet")) integrationTypes.push("usenet");
|
||||
if (data.some(({ type }) => type === "miscellaneous")) integrationTypes.push("miscellaneous");
|
||||
|
||||
//Set the visibility of columns depending on widget settings and available data/integrations.
|
||||
const columnVisibility: MRT_VisibilityState = {
|
||||
@@ -677,15 +681,22 @@ const ItemInfoModal = ({ items, currentIndex, opened, onClose }: ItemInfoModalPr
|
||||
<NormalizedLine itemKey="index" values={item.index} />
|
||||
<NormalizedLine itemKey="type" values={item.type} />
|
||||
<NormalizedLine itemKey="state" values={t(item.state)} />
|
||||
<NormalizedLine
|
||||
itemKey="upSpeed"
|
||||
values={item.upSpeed === undefined ? undefined : humanFileSize(item.upSpeed, "/s")}
|
||||
/>
|
||||
{item.type !== "miscellaneous" && (
|
||||
<NormalizedLine
|
||||
itemKey="upSpeed"
|
||||
values={item.upSpeed === undefined ? undefined : humanFileSize(item.upSpeed, "/s")}
|
||||
/>
|
||||
)}
|
||||
|
||||
<NormalizedLine
|
||||
itemKey="downSpeed"
|
||||
values={item.downSpeed === undefined ? undefined : humanFileSize(item.downSpeed, "/s")}
|
||||
/>
|
||||
<NormalizedLine itemKey="sent" values={item.sent === undefined ? undefined : humanFileSize(item.sent)} />
|
||||
|
||||
{item.type !== "miscellaneous" && (
|
||||
<NormalizedLine itemKey="sent" values={item.sent === undefined ? undefined : humanFileSize(item.sent)} />
|
||||
)}
|
||||
|
||||
<NormalizedLine itemKey="received" values={humanFileSize(item.received)} />
|
||||
<NormalizedLine itemKey="size" values={humanFileSize(item.size)} />
|
||||
<NormalizedLine
|
||||
@@ -696,7 +707,7 @@ const ItemInfoModal = ({ items, currentIndex, opened, onClose }: ItemInfoModalPr
|
||||
unitDisplay: "narrow",
|
||||
}).format(item.progress)}
|
||||
/>
|
||||
<NormalizedLine itemKey="ratio" values={item.ratio} />
|
||||
{item.type !== "miscellaneous" && <NormalizedLine itemKey="ratio" values={item.ratio} />}
|
||||
<NormalizedLine itemKey="added" values={item.added === undefined ? "unknown" : dayjs(item.added).format()} />
|
||||
<NormalizedLine itemKey="time" values={item.time !== 0 ? dayjs().add(item.time).format() : "∞"} />
|
||||
<NormalizedLine itemKey="category" values={item.category} />
|
||||
|
||||
@@ -63,6 +63,9 @@ export const { definition, componentLoader } = createWidgetDefinition("downloads
|
||||
showCompletedTorrent: factory.switch({
|
||||
defaultValue: true,
|
||||
}),
|
||||
showCompletedHttp: factory.switch({
|
||||
defaultValue: true,
|
||||
}),
|
||||
activeTorrentThreshold: factory.number({
|
||||
//in KiB/s
|
||||
validate: z.number().min(0),
|
||||
@@ -95,6 +98,10 @@ export const { definition, componentLoader } = createWidgetDefinition("downloads
|
||||
shouldHide: (_, integrationKinds) =>
|
||||
!getIntegrationKindsByCategory("torrent").some((kinds) => integrationKinds.includes(kinds)),
|
||||
},
|
||||
showCompletedHttp: {
|
||||
shouldHide: (_, integrationKinds) =>
|
||||
!getIntegrationKindsByCategory("miscellaneous").some((kinds) => integrationKinds.includes(kinds)),
|
||||
},
|
||||
activeTorrentThreshold: {
|
||||
shouldHide: (_, integrationKinds) =>
|
||||
!getIntegrationKindsByCategory("torrent").some((kinds) => integrationKinds.includes(kinds)),
|
||||
|
||||
Reference in New Issue
Block a user