Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Warn before leaving the page during an in-flight upload (#307)
Clever Monkey93d36c37830c
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 66ba51e8..064724a7 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -3680,6 +3680,17 @@ document.addEventListener('DOMContentLoaded', async () => {e.returnValue = ''; // Chrome requires thisreturn 'You have an unsaved recording. Are you sure you want to leave?';}+ // Check for uploads still in flight. A freshly-recorded file+ // may still be mid-transfer with no copy on the server yet;+ // leaving now risks losing it. (Items that already reached+ // 'pending'/'failed' are on the server or saved for retry.)+ const uploadsInFlight = uploadQueue.value.some(item =>+ item.status === 'queued' || item.status === 'ready' || item.status === 'uploading');+ if (uploadsInFlight) {+ e.preventDefault();+ e.returnValue = ''; // Chrome requires this+ return 'Uploads are still in progress. Leaving now may lose recordings that have not finished uploading.';+ }// Check for incognito recording that would be lost// Only warn if we're currently viewing the incognito recording// (if user navigated away, they've implicitly abandoned it or already been warned)