video Tools: rehydrate scan state on page refresh (parity with music)
The scan runs server-side, so on load video-scan.js now polls /api/video/scan/status and, if a scan is in progress, restores the live UI (Cancel button, moving progress bar, phase) and resumes polling — instead of showing Idle after a refresh. Also re-checks when the Tools page is shown. Because it re-emits the progress event, the Library/Dashboard scan affordances rehydrate too.
This commit is contained in:
parent
405e7097e3
commit
9ae8c243c9
2 changed files with 25 additions and 1 deletions
|
|
@ -192,6 +192,9 @@ def test_scan_module_referenced_and_isolated():
|
|||
assert "addEventListener" in _SCAN_JS
|
||||
assert "soulsync:video-scan-done" in _SCAN_JS
|
||||
assert "/api/video/scan/request" in _SCAN_JS
|
||||
# Rehydrates a running scan after a page refresh (parity with music tools).
|
||||
assert "/api/video/scan/status" in _SCAN_JS
|
||||
assert "resumeIfScanning" in _SCAN_JS
|
||||
|
||||
|
||||
def test_video_settings_reuses_real_music_settings_page():
|
||||
|
|
|
|||
|
|
@ -159,6 +159,24 @@
|
|||
.catch(function () { /* poll will reconcile */ });
|
||||
}
|
||||
|
||||
// Rehydrate after a page refresh: the scan keeps running server-side, so if
|
||||
// one is in progress, restore the UI (Cancel button, moving bar, phase) and
|
||||
// resume polling — parity with the music tools.
|
||||
function resumeIfScanning() {
|
||||
if (scanning) return;
|
||||
fetch(STATUS_URL, { headers: { 'Accept': 'application/json' } })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (s) {
|
||||
if (s && s.state === 'scanning' && !scanning) {
|
||||
scanning = true;
|
||||
reflectProgress(s);
|
||||
emit('soulsync:video-scan-progress', s);
|
||||
setTimeout(poll, 1200);
|
||||
}
|
||||
})
|
||||
.catch(function () { /* ignore */ });
|
||||
}
|
||||
|
||||
function init() {
|
||||
var triggers = document.querySelectorAll('[data-video-scan-mode],[data-video-scan]');
|
||||
for (var i = 0; i < triggers.length; i++) {
|
||||
|
|
@ -182,8 +200,11 @@
|
|||
start((e.detail && e.detail.mode) || 'full');
|
||||
});
|
||||
document.addEventListener('soulsync:video-page-shown', function (e) {
|
||||
if (e && e.detail === 'video-tools') loadToolStats();
|
||||
if (e && e.detail === 'video-tools') { loadToolStats(); resumeIfScanning(); }
|
||||
});
|
||||
// On load: if a scan is already running (page was refreshed mid-scan),
|
||||
// restore the live state instead of showing Idle.
|
||||
resumeIfScanning();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue