This is where it comes from

This commit is contained in:
Manav Rathi 2024-04-29 09:53:54 +05:30
parent 24b64f9522
commit 75c058fc4c
No known key found for this signature in database

View file

@ -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<File[]>([]);
const inputRef = useRef<HTMLInputElement>();