From 3f17c8384791a19665811e59c26cdd9b7f3e22b7 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 20 Feb 2026 14:46:03 -0600 Subject: [PATCH] fix(purchases): persist verbose log toggle, fix dropdown stacking, wire Add to Library button - Verbose capture toggle now persists to localStorage across sessions - PurchasesView dropdown menus now have mutual exclusion (opening one closes others) - Add to Library button wired to v2_library_add_folder with download destination tracking - Added i18n keys for add-to-library success/error toasts (all 4 locales) --- .../views/PurchaseAlbumDetailView.svelte | 29 +++++++++++++++++-- src/lib/components/views/PurchasesView.svelte | 18 ++++++++---- src/lib/i18n/locales/de.json | 2 ++ src/lib/i18n/locales/en.json | 2 ++ src/lib/i18n/locales/es.json | 2 ++ src/lib/i18n/locales/fr.json | 2 ++ src/lib/stores/consoleLogStore.ts | 8 ++++- src/lib/stores/purchaseDownloadStore.ts | 2 ++ 8 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/lib/components/views/PurchaseAlbumDetailView.svelte b/src/lib/components/views/PurchaseAlbumDetailView.svelte index 5efce9229..e7282ce33 100644 --- a/src/lib/components/views/PurchaseAlbumDetailView.svelte +++ b/src/lib/components/views/PurchaseAlbumDetailView.svelte @@ -2,6 +2,7 @@ import { onMount } from 'svelte'; import { get } from 'svelte/store'; import { t } from '$lib/i18n'; + import { invoke } from '@tauri-apps/api/core'; import { ArrowLeft, Download, Check, Loader2, AlertTriangle, Library, Play } from 'lucide-svelte'; import QualityBadge from '../QualityBadge.svelte'; import Dropdown from '../Dropdown.svelte'; @@ -10,6 +11,7 @@ import { purchaseDownloads, startAlbumDownload, startTrackDownload } from '$lib/stores/purchaseDownloadStore'; import type { TrackDownloadStatus } from '$lib/stores/purchaseDownloadStore'; import { formatDuration, getQobuzImage } from '$lib/adapters/qobuzAdapters'; + import { showToast } from '$lib/stores/toastStore'; import type { PurchasedAlbum, PurchasedTrack, PurchaseFormatOption } from '$lib/types/purchases'; import type { DisplayTrack } from '$lib/types'; @@ -44,6 +46,23 @@ const downloadStatuses = $derived(albumDlState?.trackStatuses ?? {}); const isDownloadingAll = $derived(albumDlState?.isDownloadingAll ?? false); const allComplete = $derived(albumDlState?.allComplete ?? false); + const downloadDestination = $derived(albumDlState?.destination ?? null); + + let addingToLibrary = $state(false); + + async function handleAddToLibrary() { + if (!downloadDestination || addingToLibrary) return; + addingToLibrary = true; + try { + await invoke('v2_library_add_folder', { path: downloadDestination }); + showToast(get(t)('purchases.addToLibrarySuccess'), 'success'); + } catch (err) { + console.error('Failed to add folder to library:', err); + showToast(get(t)('purchases.addToLibraryError'), 'error'); + } finally { + addingToLibrary = false; + } + } function formatPurchaseDate(ts?: number): string { if (!ts) return ''; @@ -301,10 +320,14 @@ {/if} - {#if allComplete} + {#if allComplete && downloadDestination}
- {$t('purchases.addToLibraryDesc')} diff --git a/src/lib/components/views/PurchasesView.svelte b/src/lib/components/views/PurchasesView.svelte index 038f0cf06..0e78c3126 100644 --- a/src/lib/components/views/PurchasesView.svelte +++ b/src/lib/components/views/PurchasesView.svelte @@ -101,6 +101,14 @@ $effect(() => { setUserItem('qbz-purchases-quality-filter', filterQuality); }); $effect(() => { setHideDownloaded(filterHideDownloaded); }); + /** Close all dropdown menus (mutual exclusion) */ + function closeAllMenus() { + showAlbumGroupMenu = false; + showAlbumSortMenu = false; + showFilterPanel = false; + showTrackGroupMenu = false; + } + const albumSortOptions = [ { value: 'date' as SortBy, labelKey: 'purchases.sort.date' }, { value: 'artist' as SortBy, labelKey: 'purchases.sort.artist' }, @@ -501,7 +509,7 @@