Add extensive debug logging to LocalLibraryView offline mode

Added detailed console logs to track execution flow:
- shouldExcludeNetworkFolders: logs offline state, reason, settings
- loadLibraryData: logs each step including invoke calls and responses
- Error handling with try/catch in shouldExcludeNetworkFolders

This will help identify where the infinite spinner occurs in offline mode.
User reports DB may be blocking in offline - investigating.
This commit is contained in:
vicrodh committed 2026-01-20 02:23:46 -06:00
1 parent 36f8b9a6a4
commit 2b4b59fc93
1 file changed
+41 -21
@@ -354,42 +354,62 @@
* - Offline manual: Hide network content ONLY if user disabled the setting
*/
function shouldExcludeNetworkFolders(): boolean {
if (!isOffline) return false;
try {
console.log('[LocalLibrary] shouldExcludeNetworkFolders called, isOffline:', isOffline);
if (!isOffline) return false;
const reason = getOfflineReason();
const offlineSettings = getOfflineSettings();
const reason = getOfflineReason();
const offlineSettings = getOfflineSettings();
console.log('[LocalLibrary] Offline reason:', reason, 'Settings:', offlineSettings);
if (reason === 'no_network') {
// No internet connection - always hide network folders
if (reason === 'no_network') {
// No internet connection - always hide network folders
console.log('[LocalLibrary] Excluding network folders (no_network)');
return true;
}
if (reason === 'manual_override') {
// Manual offline mode - respect user preference
const exclude = !offlineSettings.showNetworkFoldersInManualOffline;
console.log('[LocalLibrary] Excluding network folders (manual):', exclude);
return exclude;
}
// Default: hide network content when offline
console.log('[LocalLibrary] Excluding network folders (default)');
return true;
} catch (err) {
console.error('[LocalLibrary] Error in shouldExcludeNetworkFolders:', err);
return false; // On error, don't filter
}
if (reason === 'manual_override') {
// Manual offline mode - respect user preference
return !offlineSettings.showNetworkFoldersInManualOffline;
}
// Default: hide network content when offline
return true;
}
async function loadLibraryData() {
console.log('[LocalLibrary] loadLibraryData START, isOffline:', isOffline);
loading = true;
error = null;
try {
const [albumsResult, statsResult] = await Promise.all([
invoke<LocalAlbum[]>('library_get_albums', {
includeHidden: false,
excludeNetworkFolders: shouldExcludeNetworkFolders()
}),
invoke<LibraryStats>('library_get_stats')
]);
const excludeNetwork = shouldExcludeNetworkFolders();
console.log('[LocalLibrary] Calling library_get_albums with excludeNetwork:', excludeNetwork);
const albumsResult = await invoke<LocalAlbum[]>('library_get_albums', {
includeHidden: false,
excludeNetworkFolders: excludeNetwork
});
console.log('[LocalLibrary] Received albums:', albumsResult.length);
console.log('[LocalLibrary] Calling library_get_stats');
const statsResult = await invoke<LibraryStats>('library_get_stats');
console.log('[LocalLibrary] Received stats:', statsResult);
albums = albumsResult;
stats = statsResult;
console.log('[LocalLibrary] loadLibraryData COMPLETE');
} catch (err) {
console.error('Failed to load library:', err);
console.error('[LocalLibrary] Failed to load library:', err);
error = String(err);
} finally {
console.log('[LocalLibrary] Setting loading = false');
loading = false;
}
}