From 02f9b40d671b07cc24e09f48d737c63595a5ba2b Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 3 Oct 2023 14:05:14 -0500 Subject: [PATCH] fix(server): library control doesn't apply to new library from the third row (#4331) --- .../user-settings-page/library-list.svelte | 242 +++++++++--------- 1 file changed, 121 insertions(+), 121 deletions(-) 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} - + + {#if library.type === LibraryType.External} + + {:else if library.type === LibraryType.Upload} + + {/if} - - {#if library.type === LibraryType.External} - - {:else if library.type === LibraryType.Upload} - - {/if} - {library.name} - {#if totalCount[index] == undefined} - - - - {:else} - - {totalCount[index]} - - {diskUsage[index]} {diskUsageUnit[index]} - {/if} - - - - - {#if showContextMenu} - - onMenuExit()}> - onRenameClicked(index)} text="Rename" /> - - {#if libraryType === LibraryType.External} - onEditImportPathClicked(index)} text="Edit Import Paths" /> - onScanSettingClicked(index)} text="Scan Settings" /> -
- onScanNewLibraryClicked(library.id)} - text="Scan New Library Files" - /> - onScanAllLibraryFilesClicked(library.id)} - text="Re-scan All Library Files" - subtitle={'Only refreshes modified files'} - /> - onForceScanAllLibraryFilesClicked(library.id)} - text="Force Re-scan All Library Files" - subtitle={'Refreshes every file'} - /> -
- onRemoveOfflineFilesClicked(library.id)} - text="Remove Offline Files" - /> - onDeleteLibraryClicked(index, library)}> -

Delete library

-
- {/if} -
-
- {/if} + {library.name} + {#if totalCount[index] == undefined} + + - - {#if renameLibrary === index} -
- (renameLibrary = null)} /> -
+ {:else} + + {totalCount[index]} + + {diskUsage[index]} {diskUsageUnit[index]} {/if} - {#if editImportPaths === index} -
- (editImportPaths = null)} - /> -
- {/if} - {#if editScanSettings === index} -
- (editScanSettings = null)} - /> -
- {/if} - {/key} + + + + + {#if showContextMenu} + + onMenuExit()}> + onRenameClicked()} text={`Rename`} /> + + {#if selectedLibrary && selectedLibrary.type === LibraryType.External} + onEditImportPathClicked()} text="Edit Import Paths" /> + onScanSettingClicked()} text="Scan Settings" /> +
+ onScanNewLibraryClicked()} text="Scan New Library Files" /> + onScanAllLibraryFilesClicked()} + text="Re-scan All Library Files" + subtitle={'Only refreshes modified files'} + /> + onForceScanAllLibraryFilesClicked()} + text="Force Re-scan All Library Files" + subtitle={'Refreshes every file'} + /> +
+ onRemoveOfflineFilesClicked()} text="Remove Offline Files" /> + onDeleteLibraryClicked()}> +

Delete library

+
+ {/if} +
+
+ {/if} + + + {#if renameLibrary === index} +
+ (renameLibrary = null)} /> +
+ {/if} + {#if editImportPaths === index} +
+ (editImportPaths = null)} /> +
+ {/if} + {#if editScanSettings === index} +
+ (editScanSettings = null)} + /> +
+ {/if} {/each}