A pure move (git mv, history kept): 333 files leave components/, which now holds only the platform layer (ui/) and the legal pages. The shell is the frame (App, header, nav rail, palette, boot); each page lives in modules/<page>/ with its rail, store and tests; what several pages share sits in features/<name>/; the shared-link page is watch/. Domain-free helpers went straight to ui/ (ViewSwitcher, FilterRail, the confirm dialog, the language switcher, the copy rows). Every relative specifier was rewritten (imports, dynamic imports, vi.mock, new URL), and the contract tests that scan sources now scan the whole app source, not only components/ — each glob was counted before and after so none went green over fewer files. The locale-format rule matched `/src/components/` only, so the move would have taken ~300 files out from under its i18n-singleton check; it now covers every folder that holds components, with a test per folder.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { lazy, Suspense, useEffect } from "react";
|
|
import {
|
|
asDownloadLink,
|
|
clearPendingDownload,
|
|
pasteIsForThePage,
|
|
requestDownload,
|
|
usePendingDownload,
|
|
} from "../../lib/downloadIntake";
|
|
|
|
const DownloadDialog = lazy(() => import("./DownloadDialog"));
|
|
|
|
// The app's one download dialog (lib/downloadIntake), and the paste that opens it: a lone http(s)
|
|
// link pasted onto any page — not into a field — is downloaded, the profile picked in the dialog.
|
|
export default function DownloadIntake() {
|
|
const source = usePendingDownload();
|
|
|
|
useEffect(() => {
|
|
const onPaste = (e: ClipboardEvent) => {
|
|
if (e.defaultPrevented || !pasteIsForThePage(e.target)) return;
|
|
const link = asDownloadLink(e.clipboardData?.getData("text/plain"));
|
|
if (!link) return;
|
|
e.preventDefault();
|
|
requestDownload(link);
|
|
};
|
|
document.addEventListener("paste", onPaste);
|
|
return () => document.removeEventListener("paste", onPaste);
|
|
}, []);
|
|
|
|
return (
|
|
<Suspense fallback={null}>
|
|
{/* The link itself under the title: a paste can be an accident, and this says what it was. */}
|
|
{source && (
|
|
<DownloadDialog
|
|
key={source}
|
|
source={source}
|
|
title={source}
|
|
onClose={clearPendingDownload}
|
|
/>
|
|
)}
|
|
</Suspense>
|
|
);
|
|
}
|