Live-update queue list when upload status changes
Storage.updatePhoto() now fires a 'photo-updated' CustomEvent so the queue page refreshes immediately (300ms debounce) when the sync engine changes a photo's status, instead of waiting for the 5s poll. Also reduces background poll to 30s (just a fallback now), and revokes stale ObjectURLs on each rebuild to prevent memory leaks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -411,6 +411,10 @@ async function loadQueue() {
|
||||
}
|
||||
|
||||
emptyState.style.display = 'none';
|
||||
// Revoke old ObjectURLs before rebuilding to prevent memory leaks
|
||||
queueList.querySelectorAll('img[src^="blob:"]').forEach(img => {
|
||||
URL.revokeObjectURL(img.src);
|
||||
});
|
||||
queueList.innerHTML = '';
|
||||
|
||||
// Show active uploads first (newest first)
|
||||
@@ -610,10 +614,23 @@ window.addEventListener('offline', () => {
|
||||
document.getElementById('sync-now-btn').disabled = true;
|
||||
});
|
||||
|
||||
// Refresh queue periodically
|
||||
// Live updates: listen for photo status changes from the sync engine
|
||||
let refreshTimer = null;
|
||||
window.addEventListener('photo-updated', () => {
|
||||
// Debounce: rapid status transitions (pending→uploading→verified)
|
||||
// would otherwise trigger multiple full rebuilds
|
||||
if (refreshTimer) clearTimeout(refreshTimer);
|
||||
refreshTimer = setTimeout(() => {
|
||||
refreshTimer = null;
|
||||
loadQueue();
|
||||
updateStats();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// Fallback: full refresh every 30s in case events are missed
|
||||
setInterval(() => {
|
||||
loadQueue();
|
||||
updateStats();
|
||||
}, 5000);
|
||||
}, 30000);
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user