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:
1 parent
36f8b9a6a4
commit
2b4b59fc93
1 file changed
+28
-8
@@ -354,42 +354,62 @@
|
|||||||
* - Offline manual: Hide network content ONLY if user disabled the setting
|
* - Offline manual: Hide network content ONLY if user disabled the setting
|
||||||
*/
|
*/
|
||||||
function shouldExcludeNetworkFolders(): boolean {
|
function shouldExcludeNetworkFolders(): boolean {
|
||||||
|
try {
|
||||||
|
console.log('[LocalLibrary] shouldExcludeNetworkFolders called, isOffline:', isOffline);
|
||||||
if (!isOffline) return false;
|
if (!isOffline) return false;
|
||||||
|
|
||||||
const reason = getOfflineReason();
|
const reason = getOfflineReason();
|
||||||
const offlineSettings = getOfflineSettings();
|
const offlineSettings = getOfflineSettings();
|
||||||
|
console.log('[LocalLibrary] Offline reason:', reason, 'Settings:', offlineSettings);
|
||||||
|
|
||||||
if (reason === 'no_network') {
|
if (reason === 'no_network') {
|
||||||
// No internet connection - always hide network folders
|
// No internet connection - always hide network folders
|
||||||
|
console.log('[LocalLibrary] Excluding network folders (no_network)');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reason === 'manual_override') {
|
if (reason === 'manual_override') {
|
||||||
// Manual offline mode - respect user preference
|
// Manual offline mode - respect user preference
|
||||||
return !offlineSettings.showNetworkFoldersInManualOffline;
|
const exclude = !offlineSettings.showNetworkFoldersInManualOffline;
|
||||||
|
console.log('[LocalLibrary] Excluding network folders (manual):', exclude);
|
||||||
|
return exclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default: hide network content when offline
|
// Default: hide network content when offline
|
||||||
|
console.log('[LocalLibrary] Excluding network folders (default)');
|
||||||
return true;
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[LocalLibrary] Error in shouldExcludeNetworkFolders:', err);
|
||||||
|
return false; // On error, don't filter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadLibraryData() {
|
async function loadLibraryData() {
|
||||||
|
console.log('[LocalLibrary] loadLibraryData START, isOffline:', isOffline);
|
||||||
loading = true;
|
loading = true;
|
||||||
error = null;
|
error = null;
|
||||||
try {
|
try {
|
||||||
const [albumsResult, statsResult] = await Promise.all([
|
const excludeNetwork = shouldExcludeNetworkFolders();
|
||||||
invoke<LocalAlbum[]>('library_get_albums', {
|
console.log('[LocalLibrary] Calling library_get_albums with excludeNetwork:', excludeNetwork);
|
||||||
|
|
||||||
|
const albumsResult = await invoke<LocalAlbum[]>('library_get_albums', {
|
||||||
includeHidden: false,
|
includeHidden: false,
|
||||||
excludeNetworkFolders: shouldExcludeNetworkFolders()
|
excludeNetworkFolders: excludeNetwork
|
||||||
}),
|
});
|
||||||
invoke<LibraryStats>('library_get_stats')
|
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;
|
albums = albumsResult;
|
||||||
stats = statsResult;
|
stats = statsResult;
|
||||||
|
console.log('[LocalLibrary] loadLibraryData COMPLETE');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load library:', err);
|
console.error('[LocalLibrary] Failed to load library:', err);
|
||||||
error = String(err);
|
error = String(err);
|
||||||
} finally {
|
} finally {
|
||||||
|
console.log('[LocalLibrary] Setting loading = false');
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user