diff --git a/src/lib/components/views/LocalLibraryView.svelte b/src/lib/components/views/LocalLibraryView.svelte index d3961d271..6a65f217b 100644 --- a/src/lib/components/views/LocalLibraryView.svelte +++ b/src/lib/components/views/LocalLibraryView.svelte @@ -9,6 +9,7 @@ } from 'lucide-svelte'; import FolderSettingsModal from '../FolderSettingsModal.svelte'; import { t } from '$lib/i18n'; + import { downloadSettingsVersion } from '$lib/stores/downloadSettingsStore'; import AlbumCard from '../AlbumCard.svelte'; import TrackRow from '../TrackRow.svelte'; import { @@ -217,6 +218,18 @@ let unsubscribeNav: (() => void) | null = null; let unsubscribeOffline: (() => void) | null = null; + // Reactive effect: reload library when download settings change + $effect(() => { + // Access the store value to create a reactive dependency + const version = $downloadSettingsVersion; + + // Skip the initial mount (version 0) + if (version > 0) { + console.log('Download settings changed, reloading library data'); + loadLibraryData(); + } + }); + onMount(() => { loadLibraryData(); loadFolders(); diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 26dbc5479..84af78d35 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -12,6 +12,7 @@ openDownloadCacheFolder, type DownloadCacheStats } from '$lib/stores/downloadState'; + import { notifyDownloadSettingsChanged } from '$lib/stores/downloadSettingsStore'; import { clearCache as clearLyricsCache } from '$lib/stores/lyricsStore'; import { getToastsEnabled, @@ -631,6 +632,8 @@ try { await invoke('set_show_downloads_in_library', { show: enabled }); showQobuzDownloadsInLibrary = enabled; + // Notify LocalLibraryView to refresh + notifyDownloadSettingsChanged(); } catch (e) { console.error('Failed to update show downloads setting:', e); } diff --git a/src/lib/stores/downloadSettingsStore.ts b/src/lib/stores/downloadSettingsStore.ts new file mode 100644 index 000000000..37140b71b --- /dev/null +++ b/src/lib/stores/downloadSettingsStore.ts @@ -0,0 +1,16 @@ +import { writable } from 'svelte/store'; + +/** + * Store to track download settings changes + * Increments whenever download settings are updated (download root or show_in_library) + * Components can subscribe to this to refresh when settings change + */ +export const downloadSettingsVersion = writable(0); + +/** + * Call this whenever download settings are updated + * This triggers a refresh in components that subscribe to downloadSettingsVersion + */ +export function notifyDownloadSettingsChanged() { + downloadSettingsVersion.update(n => n + 1); +}