diff --git a/src/components/organisms/Sidebar.svelte b/src/components/organisms/Sidebar.svelte deleted file mode 100644 index 1155231..0000000 --- a/src/components/organisms/Sidebar.svelte +++ /dev/null @@ -1,199 +0,0 @@ - - -{#if sidebarOpen} - -{:else} -
- -
-{/if} - - - diff --git a/src/components/organisms/Sidebar.tsx b/src/components/organisms/Sidebar.tsx index 0fe000e..96cfcaa 100644 --- a/src/components/organisms/Sidebar.tsx +++ b/src/components/organisms/Sidebar.tsx @@ -1,7 +1,7 @@ import { LibraryState, useLibrary } from "@/lib/contexts/library"; import { Button, Divider, Modal, Stack, Title } from "@mantine/core"; import { useCallback, useEffect, useState } from "react"; -import { ImportableBookMetadata, LibraryAuthor } from "@/bindings"; +import { ImportableBookMetadata, LibraryAuthor, commands } from "@/bindings"; import { useDisclosure } from "@mantine/hooks"; import { AddBookForm, @@ -190,8 +190,17 @@ export const Sidebar = () => { }; const setNewLibraryPath = useCallback( async (form: SwitchLibraryForm) => { - await set("calibreLibraryPath", form.libraryPath); - closeSwitchLibraryModal(); + const selectedIsValid = await commands.clbQueryIsPathValidLibrary( + form.libraryPath, + ); + + if (selectedIsValid) { + await set("calibreLibraryPath", form.libraryPath); + closeSwitchLibraryModal(); + } else { + // TODO: You could create a new library, if you like. + console.error("Invalid library path selected"); + } }, [closeSwitchLibraryModal, set], );