From 75c058fc4c9abbb6acfbf556482adfb869dc5f04 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 29 Apr 2024 09:53:54 +0530 Subject: [PATCH] This is where it comes from --- web/packages/shared/hooks/useFileInput.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/web/packages/shared/hooks/useFileInput.tsx b/web/packages/shared/hooks/useFileInput.tsx index 3f7f2d4321..4eb346d39c 100644 --- a/web/packages/shared/hooks/useFileInput.tsx +++ b/web/packages/shared/hooks/useFileInput.tsx @@ -1,18 +1,23 @@ import { useCallback, useRef, useState } from "react"; /** - * TODO (MR): Understand how this is happening, and validate it further (on - * first glance this is correct). - * * [Note: File paths when running under Electron] * * We have access to the absolute path of the web {@link File} object when we * are running in the context of our desktop app. * + * https://www.electronjs.org/docs/latest/api/file-object + * * This is in contrast to the `webkitRelativePath` that we get when we're * running in the browser, which is the relative path to the directory that the * user selected (or just the name of the file if the user selected or * drag/dropped a single one). + * + * Note that this is a deprecated approach. From Electron docs: + * + * > Warning: The path property that Electron adds to the File interface is + * > deprecated and will be removed in a future Electron release. We recommend + * > you use `webUtils.getPathForFile` instead. */ export interface FileWithPath extends File { readonly path?: string; @@ -49,7 +54,10 @@ interface UseFileInputParams { * accept can be an extension or a MIME type (See * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept). */ -export default function useFileInput({ directory, accept }: UseFileInputParams) { +export default function useFileInput({ + directory, + accept, +}: UseFileInputParams) { const [selectedFiles, setSelectedFiles] = useState([]); const inputRef = useRef();