Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Fix incognito data lingering in sessionStorage after navigation
Murtaza Nasir18c8f7fa779a
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 4d8bdfea..e8b6d438 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -2035,6 +2035,16 @@ document.addEventListener('DOMContentLoaded', async () => {// Destroy editor when leaving recording viewuiComposable.destroyRecordingNotesEditor();}++ // Clear incognito data when navigating away from detail view+ // This ensures incognito data doesn't linger when user goes to upload/recording view+ if (oldView === 'detail' && newView !== 'detail') {+ if (uploadComposable.hasIncognitoRecording()) {+ console.log('[Incognito] Clearing data on view change from detail');+ sessionStorage.removeItem('speakr_incognito_recording');+ incognitoRecording.value = null;+ }+ }});// Watch for mobile tab changes to reinitialize editors if still in edit mode@@ -2116,6 +2126,14 @@ document.addEventListener('DOMContentLoaded', async () => {loadTokenBudget()]);+ // Clean up orphaned incognito data if we're not viewing incognito recording+ // This can happen if user navigated away without the cleanup triggering+ if (uploadComposable.hasIncognitoRecording() && selectedRecording.value?.id !== 'incognito') {+ console.log('[App] Cleaning up orphaned incognito data from sessionStorage');+ sessionStorage.removeItem('speakr_incognito_recording');+ incognitoRecording.value = null;+ }+// Load configtry {const response = await fetch('/api/config');@@ -2186,7 +2204,9 @@ document.addEventListener('DOMContentLoaded', async () => {return 'You have an unsaved recording. Are you sure you want to leave?';}// Check for incognito recording that would be lost- if (uploadComposable.hasIncognitoRecording()) {+ // Only warn if we're currently viewing the incognito recording+ // (if user navigated away, they've implicitly abandoned it or already been warned)+ if (uploadComposable.hasIncognitoRecording() && selectedRecording.value?.id === 'incognito') {e.preventDefault();e.returnValue = ''; // Chrome requires thisreturn 'You have an incognito recording that will be lost. Are you sure you want to leave?';diff --git a/static/js/modules/composables/recordings.js b/static/js/modules/composables/recordings.jsindex 1ba915cb..abdbf435 100644--- a/static/js/modules/composables/recordings.js+++ b/static/js/modules/composables/recordings.js@@ -179,11 +179,21 @@ export function useRecordings(state, utils, reprocessComposable) {if (!confirm('Switching to another recording will discard your incognito recording. Continue?')) {return;}- // Clear incognito recording+ // Clear incognito recording immediately - this is the "incognito" promiseIncognitoStorage.clearIncognitoRecording();incognitoRecording.value = null;}+ // Also clear any orphaned incognito data when selecting a non-incognito recording+ // This handles edge cases like page refresh where the above check doesn't trigger+ if (recording?.id !== 'incognito' && IncognitoStorage.hasIncognitoRecording()) {+ console.log('[Incognito] Clearing orphaned incognito data');+ IncognitoStorage.clearIncognitoRecording();+ if (incognitoRecording) {+ incognitoRecording.value = null;+ }+ }+// Reset modal audio state when switching recordingsif (utils.resetModalAudioState) {utils.resetModalAudioState();