fix(ui): Optimize batch recovery UX (no popups, single scan)
This commit is contained in:
parent
3186dfb942
commit
985a05858a
1 changed files with 24 additions and 8 deletions
|
|
@ -627,9 +627,9 @@
|
||||||
} catch (e) { alert("Error: " + e); }
|
} catch (e) { alert("Error: " + e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startRecovery(filepath, btn) {
|
async function startRecovery(filepath, btn, isBatch = false) {
|
||||||
console.log("startRecovery clicked for:", filepath);
|
console.log("startRecovery clicked for:", filepath);
|
||||||
if (!confirm("Start recovery for this file? This will try to fetch metadata and move it to the Import folder.")) return;
|
if (!isBatch && !confirm("Start recovery for this file? This will try to fetch metadata and move it to the Import folder.")) return;
|
||||||
|
|
||||||
// Show loading state
|
// Show loading state
|
||||||
// If btn is not passed (legacy call), try to find it via event, closely.
|
// If btn is not passed (legacy call), try to find it via event, closely.
|
||||||
|
|
@ -651,15 +651,30 @@
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
alert(data.message);
|
if (!isBatch) alert(data.message);
|
||||||
|
|
||||||
// Refresh the list to reflect changes (e.g. moved to Lost Media)
|
// If batch, we mark as done visually but don't rescan yet
|
||||||
scanRecoveryFiles();
|
if (btn && isBatch && data.success) {
|
||||||
|
btn.innerHTML = '<i class="bi bi-check-lg"></i> Done';
|
||||||
|
btn.classList.remove('btn-success');
|
||||||
|
btn.classList.add('btn-secondary');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh the list only if NOT batch (batch does it at end)
|
||||||
|
if (!isBatch) scanRecoveryFiles();
|
||||||
|
|
||||||
|
return data.success; // Return status for batch loop
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert("Error: " + e);
|
if (!isBatch) alert("Error: " + e);
|
||||||
|
if (btn && isBatch) {
|
||||||
|
btn.innerHTML = '<i class="bi bi-x-lg"></i> Err';
|
||||||
|
btn.classList.add('btn-danger');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (btn) {
|
// Restore button only if NOT batch (batch keeps them marked done)
|
||||||
|
if (btn && !isBatch) {
|
||||||
btn.innerHTML = originalHtml;
|
btn.innerHTML = originalHtml;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
@ -776,7 +791,7 @@
|
||||||
if (match) {
|
if (match) {
|
||||||
const path = match[1];
|
const path = match[1];
|
||||||
try {
|
try {
|
||||||
await startRecovery(path, btn);
|
await startRecovery(path, btn, true);
|
||||||
successCount++;
|
successCount++;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Batch error for " + path, e);
|
console.error("Batch error for " + path, e);
|
||||||
|
|
@ -786,6 +801,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alert("Batch Complete! Processed: " + buttons.length);
|
alert("Batch Complete! Processed: " + buttons.length);
|
||||||
|
scanRecoveryFiles();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue