Fix LocalLibrary not respecting 'Show in Local Library' setting

Problem: When user toggled the "Show Qobuz Downloads in Local Library"
setting in Settings, LocalLibraryView didn't refresh, so downloaded
tracks continued to appear even when the setting was disabled.

Root cause: LocalLibraryView only loaded data onMount and had no
mechanism to detect when download settings changed.

Solution:
- Created downloadSettingsStore with version tracking
- SettingsView notifies store when setting changes
- LocalLibraryView subscribes via $effect() and reloads data

Backend was already correctly filtering by the setting - this was
purely a frontend reactivity issue.

Files changed:
- src/lib/stores/downloadSettingsStore.ts (new)
- src/lib/components/views/SettingsView.svelte
- src/lib/components/views/LocalLibraryView.svelte
This commit is contained in:
vicrodh committed 2026-01-20 00:26:29 -06:00
1 parent 0d147a41b0
commit 51cfcd1c32
3 files changed
+32

No files matched your search

@@ -9,6 +9,7 @@
} from 'lucide-svelte'; } from 'lucide-svelte';
import FolderSettingsModal from '../FolderSettingsModal.svelte'; import FolderSettingsModal from '../FolderSettingsModal.svelte';
import { t } from '$lib/i18n'; import { t } from '$lib/i18n';
import { downloadSettingsVersion } from '$lib/stores/downloadSettingsStore';
import AlbumCard from '../AlbumCard.svelte'; import AlbumCard from '../AlbumCard.svelte';
import TrackRow from '../TrackRow.svelte'; import TrackRow from '../TrackRow.svelte';
import { import {
@@ -217,6 +218,18 @@
let unsubscribeNav: (() => void) | null = null; let unsubscribeNav: (() => void) | null = null;
let unsubscribeOffline: (() => 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(() => { onMount(() => {
loadLibraryData(); loadLibraryData();
loadFolders(); loadFolders();
@@ -12,6 +12,7 @@
openDownloadCacheFolder, openDownloadCacheFolder,
type DownloadCacheStats type DownloadCacheStats
} from '$lib/stores/downloadState'; } from '$lib/stores/downloadState';
import { notifyDownloadSettingsChanged } from '$lib/stores/downloadSettingsStore';
import { clearCache as clearLyricsCache } from '$lib/stores/lyricsStore'; import { clearCache as clearLyricsCache } from '$lib/stores/lyricsStore';
import { import {
getToastsEnabled, getToastsEnabled,
@@ -631,6 +632,8 @@
try { try {
await invoke('set_show_downloads_in_library', { show: enabled }); await invoke('set_show_downloads_in_library', { show: enabled });
showQobuzDownloadsInLibrary = enabled; showQobuzDownloadsInLibrary = enabled;
// Notify LocalLibraryView to refresh
notifyDownloadSettingsChanged();
} catch (e) { } catch (e) {
console.error('Failed to update show downloads setting:', e); console.error('Failed to update show downloads setting:', e);
} }
+16
View File
@@ -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);
}