Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Fix ?upload=1 not opening the modal — loadRecordings auto-selects the last viewed recording via an async selectRecording() it does NOT await, so the async body of that selection completed AFTER my switchToUploadView() call and reset showUploadModal=false on its detail-view transition (visible to the user as the URL stripping the param but the modal never appearing); now defers the switchToUploadView() call with a setTimeout(0) so it runs in a later macrotask after the pending async select resolves, then awaits nextTick for a defensive belt-and-braces against any reactive watcher chains the selection triggered; the URL cleanup runs immediately (synchronously) so a refresh during the deferred window still doesn't re-trigger the modal — the only side effect of the timing is that the user sees the recording flash briefly before the modal opens over it, which is acceptable and matches what happens when they click the regular New Recording button from a detail view

Murtaza Nasir3b9bb15fa78c
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index 3809aca7..e3a6404a 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -3206,18 +3206,29 @@ document.addEventListener('DOMContentLoaded', async () => {
]);
// Open the upload modal directly when arriving from
- // inquire mode's "+ New Recording" button (or any other
- // entry point that wants to deep-link into the upload
- // flow). Strip the query param after handling so a
- // refresh doesn't re-trigger the modal.
+ // inquire mode's "+ New Recording" button (or any
+ // other entry point that wants to deep-link into the
+ // upload flow). loadRecordings auto-selects the last
+ // viewed recording via an async selectRecording() it
+ // does NOT await, so that async body completes after
+ // the current task and resets showUploadModal=false
+ // on the detail-view transition; we defer the modal
+ // open with a setTimeout(0) so it runs in a later
+ // task after the pending select resolves, plus
+ // another nextTick to be defensive. Strip the query
+ // param after handling so a refresh doesn't
+ // re-trigger.
try {
const params = new URLSearchParams(window.location.search);
if (params.get('upload') === '1') {
- uiComposable.switchToUploadView();
params.delete('upload');
const qs = params.toString();
const newUrl = window.location.pathname + (qs ? '?' + qs : '') + window.location.hash;
window.history.replaceState({}, '', newUrl);
+ setTimeout(async () => {
+ await nextTick();
+ uiComposable.switchToUploadView();
+ }, 0);
}
} catch (_) { /* no-op: param parsing/replaceState are best-effort */ }