diff --git a/frontend/src/components/SkeletonLoader.tsx b/frontend/src/components/SkeletonLoader.tsx index 6d083f8f..e2fc37cf 100644 --- a/frontend/src/components/SkeletonLoader.tsx +++ b/frontend/src/components/SkeletonLoader.tsx @@ -214,15 +214,26 @@ const SkeletonLoader: React.FC = ({ {Array.from({ length: count }).map((_, idx) => (
-
-
-
+
+
+
+
+
+
+
-
-
-
+ +
+
+
+
+
+
+
+
+
))} diff --git a/frontend/src/settings/Sources.tsx b/frontend/src/settings/Sources.tsx index 3f867966..e0473bb8 100644 --- a/frontend/src/settings/Sources.tsx +++ b/frontend/src/settings/Sources.tsx @@ -16,7 +16,6 @@ import DiscIcon from '../assets/disc.svg'; import ContextMenu, { MenuOption } from '../components/ContextMenu'; import Pagination from '../components/DocumentPagination'; import DropdownMenu from '../components/DropdownMenu'; -import Input from '../components/Input'; import SkeletonLoader from '../components/SkeletonLoader'; import { useDarkTheme, useLoaderState } from '../hooks'; import ConfirmationModal from '../modals/ConfirmationModal'; @@ -58,6 +57,7 @@ export default function Sources({ const token = useSelector(selectToken); const [searchTerm, setSearchTerm] = useState(''); + const [debouncedSearchTerm, setDebouncedSearchTerm] = useState(''); const [modalState, setModalState] = useState('INACTIVE'); const [isOnboarding, setIsOnboarding] = useState(false); const [loading, setLoading] = useLoaderState(false); @@ -116,6 +116,14 @@ export default function Sources({ document: null, }); + useEffect(() => { + const timer = setTimeout(() => { + setDebouncedSearchTerm(searchTerm); + }, 500); + + return () => clearTimeout(timer); + }, [searchTerm]); + const refreshDocs = useCallback( ( field: 'date' | 'tokens' | undefined, @@ -148,7 +156,7 @@ export default function Sources({ newSortOrder, page, rowsPerPg, - searchTerm, + debouncedSearchTerm, token, ) .then((data) => { @@ -160,7 +168,7 @@ export default function Sources({ setLoading(false); }); }, - [currentPage, rowsPerPage, sortField, sortOrder, searchTerm], + [currentPage, rowsPerPage, sortField, sortOrder, debouncedSearchTerm], ); const handleManageSync = (doc: Doc, sync_frequency: string) => { @@ -259,7 +267,7 @@ export default function Sources({ }; useEffect(() => { refreshDocs(undefined, 1, rowsPerPage); - }, [searchTerm]); + }, [debouncedSearchTerm]); return documentToView ? (
@@ -290,19 +298,21 @@ export default function Sources({ - { - setSearchTerm(e.target.value); - setCurrentPage(1); - }} - borderVariant="thin" - /> +
+ { + setSearchTerm(e.target.value); + setCurrentPage(1); + }} + className="w-full h-[32px] rounded-full border border-silver dark:border-silver/40 bg-transparent px-3 text-sm text-jet dark:text-bright-gray placeholder:text-gray-400 dark:placeholder:text-gray-500 outline-none focus:border-silver dark:focus:border-silver/60" + /> +