Show scan overlay after page reload

- Add is_scanning state tracking in AnimeService
- Add get_scan_status method to AnimeService
- Add /api/anime/scan/status endpoint to check scan state
- Add checkActiveScanStatus in JS to restore overlay on reconnect
- All 1024 tests passing
This commit is contained in:
2025-12-24 21:06:22 +01:00
parent 72ac201153
commit 19cb8c11a0
7 changed files with 98 additions and 2 deletions

View File

@@ -193,6 +193,9 @@ class AniWorldApp {
this.showToast(this.localization.getText('connected-server'), 'success');
this.updateConnectionStatus();
// Check if a scan is currently in progress (e.g., after page reload)
this.checkActiveScanStatus();
});
this.socket.on('disconnect', () => {
@@ -1278,6 +1281,43 @@ class AniWorldApp {
}
}
/**
* Check if a scan is currently in progress (useful after page reload)
* and show the progress overlay if so
*/
async checkActiveScanStatus() {
try {
const response = await this.makeAuthenticatedRequest('/api/anime/scan/status');
if (!response || !response.ok) {
console.log('Could not fetch scan status');
return;
}
const data = await response.json();
console.log('Scan status:', data);
if (data.is_scanning) {
// A scan is in progress, show the overlay
this.showScanProgressOverlay({
directory: data.directory,
total_items: data.total_items
});
// Update with current progress
this.updateScanProgressOverlay({
directories_scanned: data.directories_scanned,
files_found: data.directories_scanned,
current_directory: data.current_directory,
total_items: data.total_items
});
this.updateProcessStatus('rescan', true);
}
} catch (error) {
console.error('Error checking scan status:', error);
}
}
showLoading() {
document.getElementById('loading-overlay').classList.remove('hidden');
}