Add network folder visibility control for manual offline mode

Implemented configurable network folder visibility when in manual offline mode.

Problem:
- Previously, ALL offline modes hid network folders
- Users in manual offline mode (privacy/metered internet) may still
  have local network access and want to see network-mounted music

Solution:
- Added showNetworkFoldersInManualOffline setting (already existed in backend)
- Implemented smart filtering logic in LocalLibraryView:
  - Offline real (no_network): Always hide network folders
  - Offline manual: Hide ONLY if user disabled the setting
  - Online: Show everything
- Added toggle in Settings > Offline Mode section

Use cases:
1. Privacy: Manual offline mode but keep local network music visible
2. Metered internet: Don't stream from Qobuz but access NAS/network shares
3. Real offline: No network at all, hide everything network-based

Settings location: Settings > Offline Mode > "Show Network Folders"
Description: "Display music from network folders when in manual
offline mode (privacy/metered connection)"

Files changed:
- src/lib/components/views/LocalLibraryView.svelte
- src/lib/components/views/SettingsView.svelte
This commit is contained in:
vicrodh committed 2026-01-20 00:57:06 -06:00
1 parent fb1dfa05a4
commit 4876293ec2
2 files changed
+47 -4

No files matched your search

@@ -23,7 +23,9 @@
} from '$lib/stores/navigationStore'; } from '$lib/stores/navigationStore';
import { import {
subscribe as subscribeOffline, subscribe as subscribeOffline,
isOffline as checkIsOffline isOffline as checkIsOffline,
getOfflineReason,
getSettings as getOfflineSettings
} from '$lib/stores/offlineStore'; } from '$lib/stores/offlineStore';
import { import {
setPlaybackContext setPlaybackContext
@@ -297,7 +299,7 @@
if (!album) { if (!album) {
const allAlbums = await invoke<LocalAlbum[]>('library_get_albums', { const allAlbums = await invoke<LocalAlbum[]>('library_get_albums', {
includeHidden: false, includeHidden: false,
excludeNetworkFolders: isOffline excludeNetworkFolders: shouldExcludeNetworkFolders()
}); });
albums = allAlbums; albums = allAlbums;
album = allAlbums.find(a => a.id === albumId); album = allAlbums.find(a => a.id === albumId);
@@ -322,6 +324,32 @@
} }
} }
/**
* Determine if we should hide network folder content based on offline state
* - Not offline: Show everything
* - Offline real (no_network): Always hide network content
* - Offline manual: Hide network content ONLY if user disabled the setting
*/
function shouldExcludeNetworkFolders(): boolean {
if (!isOffline) return false;
const reason = getOfflineReason();
const offlineSettings = getOfflineSettings();
if (reason === 'no_network') {
// No internet connection - always hide network folders
return true;
}
if (reason === 'manual_override') {
// Manual offline mode - respect user preference
return !offlineSettings.showNetworkFoldersInManualOffline;
}
// Default: hide network content when offline
return true;
}
async function loadLibraryData() { async function loadLibraryData() {
loading = true; loading = true;
error = null; error = null;
@@ -329,7 +357,7 @@
const [albumsResult, statsResult] = await Promise.all([ const [albumsResult, statsResult] = await Promise.all([
invoke<LocalAlbum[]>('library_get_albums', { invoke<LocalAlbum[]>('library_get_albums', {
includeHidden: false, includeHidden: false,
excludeNetworkFolders: isOffline // Hide network music when offline excludeNetworkFolders: shouldExcludeNetworkFolders()
}), }),
invoke<LibraryStats>('library_get_stats') invoke<LibraryStats>('library_get_stats')
]); ]);
@@ -915,7 +943,7 @@
try { try {
hiddenAlbums = await invoke<LocalAlbum[]>('library_get_albums', { hiddenAlbums = await invoke<LocalAlbum[]>('library_get_albums', {
includeHidden: true, includeHidden: true,
excludeNetworkFolders: isOffline excludeNetworkFolders: shouldExcludeNetworkFolders()
}); });
const visibleAlbumIds = new Set(albums.map(a => a.id)); const visibleAlbumIds = new Set(albums.map(a => a.id));
hiddenAlbums = hiddenAlbums.filter(a => !visibleAlbumIds.has(a.id)); hiddenAlbums = hiddenAlbums.filter(a => !visibleAlbumIds.has(a.id));
@@ -695,6 +695,14 @@
} }
} }
async function handleShowNetworkFoldersChange(enabled: boolean) {
try {
await setShowNetworkFoldersInManualOffline(enabled);
} catch (error) {
console.error('Failed to set show network folders in manual offline:', error);
}
}
async function handleAllowImmediateScrobblingChange(enabled: boolean) { async function handleAllowImmediateScrobblingChange(enabled: boolean) {
try { try {
await setAllowImmediateScrobbling(enabled); await setAllowImmediateScrobbling(enabled);
@@ -1647,6 +1655,13 @@
</div> </div>
<Toggle enabled={offlineSettings.allowCastWhileOffline} onchange={handleAllowCastChange} /> <Toggle enabled={offlineSettings.allowCastWhileOffline} onchange={handleAllowCastChange} />
</div> </div>
<div class="setting-row">
<div class="setting-info">
<span class="setting-label">Show Network Folders</span>
<span class="setting-desc">Display music from network folders when in manual offline mode (privacy/metered connection)</span>
</div>
<Toggle enabled={offlineSettings.showNetworkFoldersInManualOffline} onchange={handleShowNetworkFoldersChange} />
</div>
<div class="setting-row"> <div class="setting-row">
<div class="setting-info"> <div class="setting-info">
<span class="setting-label">{$t('offline.allowImmediateScrobbling')}</span> <span class="setting-label">{$t('offline.allowImmediateScrobbling')}</span>