MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / DropZone

Function DropZone

src/components/dropzone/DropZone.tsx:24–299  ·  view source on GitHub ↗
({ children }: DropZoneProps)

Source from the content-addressed store, hash-verified

22}
23
24export function DropZone({ children }: DropZoneProps) {
25 const [isDragOver, setIsDragOver] = useState(false);
26 const [isPanelDismissed, setIsPanelDismissed] = useState(false);
27 const [isUrlModalOpen, setIsUrlModalOpen] = useState(false);
28 const { handleDrop, handleDragOver, handleBrowse } = useFileDropzone();
29 const { loadFromUrl, loadFromManifest, urlLoading, urlProgress, setUrlLoading, setUrlProgress } = useUrlLoader();
30 const {
31 data: {
32 error,
33 reconstruction,
34 touchMode,
35 hasUrlLoadRequest,
36 },
37 actions: {
38 setError,
39 },
40 } = useDropZoneStoreFacade();
41 const configInputRef = useRef<HTMLInputElement>(null);
42 const manifestInputRef = useRef<HTMLInputElement>(null);
43 const isMobile = useIsMobile();
44
45 // Handle URL loading from modal
46 const handleUrlLoad = useCallback(async (url: string) => {
47 // Set loading state IMMEDIATELY so UI responds instantly
48 setUrlLoading(true);
49 setUrlProgress({ percent: 0, message: 'Starting...' });
50 setIsUrlModalOpen(false);
51 // Yield to React to paint loading UI before starting heavy work
52 await new Promise(resolve => setTimeout(resolve, 0));
53 await loadFromUrl(url);
54 }, [loadFromUrl, setUrlLoading, setUrlProgress]);
55
56 // Handle manifest JSON file selection
57 const handleManifestFileChange = useCallback(async (e: React.ChangeEvent<HTMLInputElement>) => {
58 const file = e.target.files?.[0];
59 if (!file) return;
60
61 // Set loading state IMMEDIATELY so UI responds instantly
62 setUrlLoading(true);
63 setUrlProgress({ percent: 0, message: 'Loading manifest...' });
64 // Yield to React to paint loading UI before starting heavy work
65 await new Promise(resolve => setTimeout(resolve, 0));
66
67 try {
68 const result = parseManifestContent(await file.text());
69 if (!result.success) {
70 setError(result.errorMessage);
71 setUrlLoading(false);
72 return;
73 }
74
75 await loadFromManifest(result.manifest);
76 } catch (err) {
77 const message = err instanceof Error ? err.message : 'Unknown error';
78 setError(`Failed to load manifest: ${message}`);
79 setUrlLoading(false);
80 }
81

Callers

nothing calls this directly

Calls 15

useFileDropzoneFunction · 0.90
useUrlLoaderFunction · 0.90
useDropZoneStoreFacadeFunction · 0.90
useIsMobileFunction · 0.90
parseManifestContentFunction · 0.90
getRandomDatasetFunction · 0.90
getDatasetUrlFunction · 0.90
createExampleManifestFunction · 0.90
downloadBlobFunction · 0.90
requestConfirmationFunction · 0.90
clearPersistedSettingsFunction · 0.90
importConfigFileFunction · 0.90

Tested by

no test coverage detected