From 3ba9e901c9f17e16638c3cf542e28e26ca3305ba Mon Sep 17 00:00:00 2001 From: Galactic99 Date: Thu, 16 Apr 2026 20:36:25 +0530 Subject: [PATCH] fix:Claim the countdown run before the first await. --- src/hooks/useScreenRecorder.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts index f208013..7c9112d 100644 --- a/src/hooks/useScreenRecorder.ts +++ b/src/hooks/useScreenRecorder.ts @@ -415,6 +415,10 @@ export function useScreenRecorder(): UseScreenRecorderReturn { return; } + const runId = countdownRunId.current + 1; + countdownRunId.current = runId; + setCountdownActive(true); + let selectedSource: ProcessedDesktopSource | null = null; try { selectedSource = await window.electronAPI.getSelectedSource(); @@ -422,14 +426,17 @@ export function useScreenRecorder(): UseScreenRecorderReturn { console.warn("Failed to read selected source before countdown:", error); } - if (!selectedSource) { - alert(t("recording.selectSource")); + if (!isCountdownRunActive(runId)) { return; } - const runId = countdownRunId.current + 1; - countdownRunId.current = runId; - setCountdownActive(true); + if (!selectedSource) { + if (countdownRunId.current === runId) { + setCountdownActive(false); + } + alert(t("recording.selectSource")); + return; + } try { const values = [3, 2, 1];