fix: redirect to /setup/unresolved after series scan completes
- Add 'system_progress' event type to loading page redirect condition - Add checkUnresolvedAndRedirect() for phase=initial to handle race condition where backend initialization completes before WebSocket connects - Backend now emits series_sync progress events during initial setup - Loading page checks /api/setup/unresolved immediately on load for phase=initial - Fixes users getting stuck on loading page after setup
This commit is contained in:
@@ -451,8 +451,9 @@
|
||||
updateStep(stepId, status, msg, percent, current, total);
|
||||
|
||||
// Check for completion of series_sync
|
||||
// stepId is used because type is 'system_progress' for SYSTEM progress events
|
||||
if (metadata?.initialization_complete || (stepId === 'series_sync' && status === 'completed')) {
|
||||
// For scan_completed messages: stepId='scan_completed', no status field, no metadata
|
||||
// system_progress events are emitted by progress_service during initial setup (ProgressType.SYSTEM)
|
||||
if (metadata?.initialization_complete || type === 'scan_completed' || type === 'system_progress' || (stepId === 'series_sync' && status === 'completed')) {
|
||||
// For initial phase, series_sync completion leads to /setup/unresolved
|
||||
handleSeriesSyncComplete();
|
||||
}
|
||||
@@ -720,10 +721,42 @@
|
||||
createStep('nfo_scan', stepTitles['nfo_scan']);
|
||||
// Trigger NFO scan phase via API
|
||||
triggerNfoScanPhase();
|
||||
connectWebSocket();
|
||||
} else {
|
||||
// For initial phase, initialization already completed before this page loaded
|
||||
// Check for unresolved folders immediately and redirect
|
||||
checkUnresolvedAndRedirect();
|
||||
}
|
||||
|
||||
connectWebSocket();
|
||||
});
|
||||
|
||||
// For initial phase, check if there are unresolved folders and redirect accordingly
|
||||
// This is needed because the backend initialization completes before this page loads,
|
||||
// so WebSocket events are missed
|
||||
async function checkUnresolvedAndRedirect() {
|
||||
try {
|
||||
const response = await fetch('/api/setup/unresolved');
|
||||
if (response.ok) {
|
||||
const folders = await response.json();
|
||||
if (folders.length > 0) {
|
||||
// Unresolved folders exist - redirect to unresolved page
|
||||
clearSetupPhase();
|
||||
window.location.href = '/setup/unresolved';
|
||||
} else {
|
||||
// No unresolved folders - redirect to login
|
||||
clearSetupPhase();
|
||||
window.location.href = '/login';
|
||||
}
|
||||
} else {
|
||||
// Error - stay on page and wait for potential WebSocket events
|
||||
console.error('Failed to check unresolved folders:', response.status);
|
||||
connectWebSocket();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking unresolved folders:', error);
|
||||
// Stay on page and wait for WebSocket events
|
||||
connectWebSocket();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user