MCPcopy Create free account
hub / github.com/dailydotdev/apps / onFileChange

Function onFileChange

packages/shared/src/hooks/utils/useFileInput.ts:17–35  ·  view source on GitHub ↗
(file?: File | null)

Source from the content-addressed store, hash-verified

15}: UseFileInputProps) => {
16 const { displayToast, dismissToast } = useToastNotification();
17 const onFileChange = async (file?: File | null) => {
18 if (!file) {
19 return;
20 }
21
22 if (file.size > limitMb * MEGABYTE) {
23 displayToast(`Maximum image size is ${limitMb} MB`);
24 return;
25 }
26
27 if (acceptedTypes && !acceptedTypes.includes(file.type)) {
28 displayToast(`File type is not allowed`);
29 return;
30 }
31
32 const base64 = await blobToBase64(file);
33 dismissToast();
34 onChange(base64, file);
35 };
36
37 return { onFileChange };
38};

Callers 4

onDropFunction · 0.50
GivebackScreenshotFieldFunction · 0.50
handleAvatarDropFunction · 0.50
ShortcutEditFormFunction · 0.50

Calls 4

blobToBase64Function · 0.90
displayToastFunction · 0.85
dismissToastFunction · 0.85
onChangeFunction · 0.50

Tested by

no test coverage detected