Skip to content

Commit aa0472d

Browse files
committed
fix: resolve typecheck errors in FileSelectionPrompt and webtorrent types
1 parent 24b5a28 commit aa0472d

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/ui/components/FileSelectionPrompt.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Panel } from "./Panel";
44
import { PromptHints } from "./PromptHints";
55
import { Spinner } from "./Spinner";
66
import { COLOR, ICON } from "../theme";
7-
import { parseTrackers } from "../../sources/magnet";
87
import { formatBytes, truncate } from "../../util/format";
98

109
interface FileSelectionPromptProps {
@@ -32,7 +31,10 @@ export function FileSelectionPrompt({
3231
const [cursor, setCursor] = useState(0);
3332

3433
useEffect(() => {
35-
const magnetTrackers = parseTrackers(magnet);
34+
const magnetTrackers: string[] = [];
35+
try {
36+
new URL(magnet).searchParams.getAll("tr").forEach((t) => magnetTrackers.push(t));
37+
} catch {}
3638
const allTrackers = Array.from(new Set([...magnetTrackers, ...trackers]));
3739
const cancel = fetchMetadata(
3840
magnet,
@@ -103,7 +105,7 @@ export function FileSelectionPrompt({
103105
</Box>
104106
) : error ? (
105107
<Box paddingX={1}>
106-
<Text color={COLOR.danger}>{`Error: ${truncate(error, width - 12)}`}</Text>
108+
<Text color={COLOR.bad}>{`Error: ${truncate(error, width - 12)}`}</Text>
107109
</Box>
108110
) : (
109111
<Box flexDirection="column" width="100%">
@@ -112,7 +114,7 @@ export function FileSelectionPrompt({
112114
<Box flexGrow={1} />
113115
<Text color={COLOR.accent}>{`${selectedCount}/${totalCount} files`}</Text>
114116
</Box>
115-
{viewFiles.map((f, i) => {
117+
{viewFiles.map((f: { path: string; length: number }, i: number) => {
116118
const absIndex = offset + i;
117119
const isFocused = absIndex === cursor;
118120
const isSelected = viewSelections[i];
@@ -121,7 +123,7 @@ export function FileSelectionPrompt({
121123
<Text color={isFocused ? COLOR.accent : COLOR.text}>
122124
{isFocused ? ICON.pointer : " "}
123125
</Text>
124-
<Text color={isSelected ? COLOR.success : COLOR.text}>
126+
<Text color={isSelected ? COLOR.good : COLOR.text}>
125127
{isSelected ? "[x]" : "[ ]"}
126128
</Text>
127129
<Text> </Text>

src/webtorrent.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare module "webtorrent" {
55
name: string;
66
path: string;
77
length: number;
8+
downloaded: number;
89
select(): void;
910
deselect(): void;
1011
}

0 commit comments

Comments
 (0)