transmission, extracted from the platform into its own repository
The sixth plugin out, immediately after photos. A sidecar, a proxy router and 29 web files; no db/ directory, because there are no tables. ── The one thing that is not self-contained ── The connection lives in `service_connections`, a CORE table, reached through getServiceConnection/saveServiceConnection/getServiceCredentials. This plugin declares no schema. Deliberate: that table is the app store's shared credential store, keyed on (user_id, service), already encrypted at rest and already read by app-store/effects.ts. A private copy of the same three columns would be a second place the same fact could live, and the runbook is explicit that a move plus a data-format change gives any failure two causes. The cost, stated rather than hidden: this plugin depends on a core facility it does not own, and would break if that table changed shape. Photos, by contrast, owns photos_config outright. ── 38 palette classes paid down, mapped by meaning ── blue downloading / download speed -> info cyan checking (verifying) -> busy emerald seeding / complete -> success amber queued / stalled / warnings -> warning Collapsing blue and cyan into one tone would have lost a real distinction in the status dot, so `checking` went to `busy` — in-progress work, which is what that tone is for. ── A near-miss worth recording ── The first copy globbed *.tsx and *.ts and silently missed detail/ and dialogs/ — ten components. tsgo caught it as ten "cannot find module" errors. Worth stating because it is quiet in the other direction: had those been imported lazily, the typecheck would have passed and the panels would have broken at runtime. Check the directory tree, not the file glob. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
import type { Torrent } from '../shared';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { useTorrentMutations } from '../useTransmissionData';
|
||||
|
||||
// Transmission 4 replaced the old trackerAdd/trackerRemove/trackerReplace triple with `trackerList`: the
|
||||
// whole announce list as text, one URL per line, a blank line between tiers. Editing text is also the only
|
||||
// honest way to express tiers, which a list of rows with buttons cannot.
|
||||
|
||||
type TrackersDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; torrent: Torrent | null };
|
||||
|
||||
/** Rebuild the tier-separated text from trackerStats when the daemon didn't send trackerList. */
|
||||
function fromStats(torrent: Torrent): string {
|
||||
const tiers = new Map<number, string[]>();
|
||||
for (const t of torrent.trackerStats ?? []) {
|
||||
const list = tiers.get(t.tier) ?? [];
|
||||
list.push(t.announce);
|
||||
tiers.set(t.tier, list);
|
||||
}
|
||||
return [...tiers.entries()]
|
||||
.sort((a, b) => a[0] - b[0])
|
||||
.map(([, urls]) => urls.join('\n'))
|
||||
.join('\n\n');
|
||||
}
|
||||
|
||||
export const TrackersDialog = ({ open, onOpenChange, torrent }: TrackersDialogProps) => {
|
||||
const { set } = useTorrentMutations();
|
||||
const [text, setText] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !torrent) return;
|
||||
setText(torrent.trackerList ?? fromStats(torrent));
|
||||
}, [open, torrent]);
|
||||
|
||||
const submit = async () => {
|
||||
if (!torrent) return;
|
||||
// Trailing whitespace on a line makes Transmission reject the whole list, and pasting from a website
|
||||
// reliably brings some along.
|
||||
const normalised = text
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.join('\n');
|
||||
await set.mutateAsync({ ids: [torrent.id], trackerList: normalised });
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Trackers</DialogTitle>
|
||||
<DialogDescription className="break-words">{torrent?.name}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="tr-trackers">Announce URLs</Label>
|
||||
<Textarea
|
||||
id="tr-trackers"
|
||||
rows={10}
|
||||
value={text}
|
||||
onChange={(ev) => setText(ev.target.value)}
|
||||
className="font-mono text-xs"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
One URL per line. Leave a blank line between tiers — Transmission only falls through to the next tier when
|
||||
every tracker in the one above it fails.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{torrent?.isPrivate && (
|
||||
<p className="rounded-lg bg-warning/15 px-3 py-2 text-xs text-warning">
|
||||
This is a private torrent. Adding trackers it wasn't issued with will not help and may get you banned from
|
||||
the tracker it came from.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={submit} disabled={set.isPending}>
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user