diff --git a/client/browser/FinderFileSelect.tsx b/client/browser/FinderFileSelect.tsx index e48a72525..732c365e8 100644 --- a/client/browser/FinderFileSelect.tsx +++ b/client/browser/FinderFileSelect.tsx @@ -1,9 +1,9 @@ import React, { - forwardRef, lazy, + memo, Suspense, + useCallback, useEffect, - useImperativeHandle, useMemo, useRef, useState, @@ -14,6 +14,7 @@ import ArrowDownIcon from '../icons/arrow-down.svg'; import ArrowRightIcon from '../icons/arrow-right.svg'; import EmptyIcon from '../icons/empty.svg'; import FolderIcon from '../icons/folder.svg'; +import FolderOpenIcon from '../icons/folder-open.svg'; import RootIcon from '../icons/root.svg'; @@ -51,38 +52,17 @@ function Figure(props) { } -const FolderList = forwardRef((props: any, forwardedRef) => { - const [files, setFiles] = useState(props.files); - const [isLoading, setLoading] = useState(false); - const [searchQuery, setSearchQuery] = useState(() => { - const params = new URLSearchParams(window.location.search); - return params.get('q'); - }); - - useImperativeHandle(forwardedRef, () => ({fetchFiles})); - - async function fetchFiles(folderId) { - const params = new URLSearchParams({q: searchQuery}); - const listFilesUrl = `${props.baseUrl}list/${folderId}${searchQuery ? `?${params.toString()}` : ''}`; - setLoading(true); - const response = await fetch(listFilesUrl); - if (response.ok) { - const body = await response.json(); - setFiles(body.files); - } else { - console.error(response); - } - setLoading(false); - } +const FilesList = memo((props: any) => { + const {files, isLoading} = props; function selectFile(file) { console.log(file); } + console.log('FolderList', files); return (