diff --git a/web/src/lib/components/user-settings-page/library-list.svelte b/web/src/lib/components/user-settings-page/library-list.svelte index db2c1c4298..581a04969b 100644 --- a/web/src/lib/components/user-settings-page/library-list.svelte +++ b/web/src/lib/components/user-settings-page/library-list.svelte @@ -43,7 +43,8 @@ let dropdownOpen: boolean[] = []; let showContextMenu = false; let contextMenuPosition = { x: 0, y: 0 }; - let libraryType: LibraryType; + let selectedLibraryIndex = 0; + let selectedLibrary: LibraryResponseDto | null = null; onMount(() => { readLibraryList(); @@ -61,10 +62,12 @@ } }; - const showMenu = (event: MouseEvent, type: LibraryType) => { + const showMenu = (event: MouseEvent, library: LibraryResponseDto, index: number) => { contextMenuPosition = getContextMenuPosition(event); showContextMenu = !showContextMenu; - libraryType = type; + + selectedLibraryIndex = index; + selectedLibrary = library; }; const onMenuExit = () => { @@ -216,54 +219,63 @@ } }; - const onRenameClicked = (index: number) => { + const onRenameClicked = () => { closeAll(); - renameLibrary = index; - updateLibraryIndex = index; + renameLibrary = selectedLibraryIndex; + updateLibraryIndex = selectedLibraryIndex; }; - const onEditImportPathClicked = (index: number) => { + const onEditImportPathClicked = () => { closeAll(); - editImportPaths = index; - updateLibraryIndex = index; + editImportPaths = selectedLibraryIndex; + updateLibraryIndex = selectedLibraryIndex; }; - const onScanNewLibraryClicked = (libraryId: string) => { + const onScanNewLibraryClicked = () => { closeAll(); - handleScan(libraryId); + + if (selectedLibrary) { + handleScan(selectedLibrary.id); + } }; - const onScanSettingClicked = (index: number) => { + const onScanSettingClicked = () => { closeAll(); - editScanSettings = index; - updateLibraryIndex = index; + editScanSettings = selectedLibraryIndex; + updateLibraryIndex = selectedLibraryIndex; }; - const onScanAllLibraryFilesClicked = (libraryId: string) => { + const onScanAllLibraryFilesClicked = () => { closeAll(); - handleScanChanges(libraryId); + if (selectedLibrary) { + handleScanChanges(selectedLibrary.id); + } }; - const onForceScanAllLibraryFilesClicked = (libraryId: string) => { + const onForceScanAllLibraryFilesClicked = () => { closeAll(); - handleForceScan(libraryId); + if (selectedLibrary) { + handleForceScan(selectedLibrary.id); + } }; - const onRemoveOfflineFilesClicked = (libraryId: string) => { + const onRemoveOfflineFilesClicked = () => { closeAll(); - handleRemoveOffline(libraryId); + if (selectedLibrary) { + handleRemoveOffline(selectedLibrary.id); + } }; - const onDeleteLibraryClicked = (index: number, library: LibraryResponseDto) => { + const onDeleteLibraryClicked = () => { closeAll(); - if (confirm(`Are you sure you want to delete ${library.name} library?`) == true) { - refreshStats(index); - if (totalCount[index] > 0) { - deleteAssetCount = totalCount[index]; - confirmDeleteLibrary = library; + if (selectedLibrary && confirm(`Are you sure you want to delete ${selectedLibrary.name} library?`) == true) { + refreshStats(selectedLibraryIndex); + if (totalCount[selectedLibraryIndex] > 0) { + deleteAssetCount = totalCount[selectedLibraryIndex]; + confirmDeleteLibrary = selectedLibrary; } else { - deleteLibrary = library; + deleteLibrary = selectedLibrary; handleDelete(); } } @@ -295,104 +307,92 @@
- {#each libraries as library, index} - {#key library.id} -Delete library
-Delete library
+