MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / handleFileDrop

Function handleFileDrop

index.tsx:151–169  ·  view source on GitHub ↗
(event: DragEvent)

Source from the content-addressed store, hash-verified

149}
150
151function handleFileDrop(event: DragEvent): void {
152 const files = Array.from(event.dataTransfer?.files || []);
153 if (!files.length) return;
154
155 if (!settings.store.bypassDragDrop || !isConfigured()) return;
156 if (!isChatAreaDrop(event.target)) return;
157 if (isForumOrSlashContext(SelectedChannelStore.getChannelId())) return;
158
159 const allowed = files.filter(f => isFileTypeAllowed(f));
160 if (!allowed.length) return;
161 if (!shouldInterceptUploadFiles(allowed, getGuildIdForChannel(SelectedChannelStore.getChannelId()))) return;
162
163 event.preventDefault();
164 event.stopImmediatePropagation();
165 event.stopPropagation();
166
167 allowed.forEach(file => handledDropFiles.add(file));
168 void uploadProvidedFiles(allowed);
169}
170
171function formatBytes(bytes: number): string {
172 if (!bytes) return "";

Callers 1

startFunction · 0.85

Calls 7

isConfiguredFunction · 0.90
isFileTypeAllowedFunction · 0.90
uploadProvidedFilesFunction · 0.90
isChatAreaDropFunction · 0.85
isForumOrSlashContextFunction · 0.85
getGuildIdForChannelFunction · 0.85

Tested by

no test coverage detected