refactor: small code style
This commit is contained in:
parent
00916a1fd2
commit
c179a16d15
1 changed files with 3 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import type { FileEntry } from "../components/file-tree";
|
import type { FileEntry } from "../components/file-tree";
|
||||||
|
|
||||||
type FetchFolderFn = (
|
type FetchFolderFn = (
|
||||||
|
|
@ -19,14 +19,8 @@ type UseFileBrowserOptions = {
|
||||||
rootPath?: string;
|
rootPath?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useFileBrowser = ({
|
export const useFileBrowser = (props: UseFileBrowserOptions) => {
|
||||||
initialData,
|
const { initialData, isLoading, fetchFolder, prefetchFolder, pathTransform, rootPath = "/" } = props;
|
||||||
isLoading = false,
|
|
||||||
fetchFolder,
|
|
||||||
prefetchFolder,
|
|
||||||
pathTransform,
|
|
||||||
rootPath = "/",
|
|
||||||
}: UseFileBrowserOptions) => {
|
|
||||||
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());
|
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());
|
||||||
const [fetchedFolders, setFetchedFolders] = useState<Set<string>>(new Set([rootPath]));
|
const [fetchedFolders, setFetchedFolders] = useState<Set<string>>(new Set([rootPath]));
|
||||||
const [loadingFolders, setLoadingFolders] = useState<Set<string>>(new Set());
|
const [loadingFolders, setLoadingFolders] = useState<Set<string>>(new Set());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue