Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

prioritize recording stop over countdown cancel

Galactic99d04bab732bac
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 51c57dd94..44dece06f 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -759,12 +759,17 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
};
const toggleRecording = () => {
+ if (recording) {
+ stopRecording.current();
+ return;
+ }
+
if (countdownActive) {
cancelCountdown();
return;
}
- recording ? stopRecording.current() : void startRecordCountdown();
+ void startRecordCountdown();
};
const restartRecording = async () => {
@@ -827,19 +832,23 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
}, [getRecordingDurationMs, paused, recording]);
const cancelRecording = () => {
+ const activeScreenRecorder = screenRecorder.current;
+ if (
+ activeScreenRecorder?.recorder.state === "recording" ||
+ activeScreenRecorder?.recorder.state === "paused"
+ ) {
+ const activeRecordingId = recordingId.current;
+ discardRecordingId.current = activeRecordingId;
+ allowAutoFinalize.current = false;
+
+ stopRecording.current();
+ return;
+ }
+
if (countdownActive) {
cancelCountdown();
return;
}
-
- const activeScreenRecorder = screenRecorder.current;
- if (!activeScreenRecorder || activeScreenRecorder.recorder.state !== "recording") return;
-
- const activeRecordingId = recordingId.current;
- discardRecordingId.current = activeRecordingId;
- allowAutoFinalize.current = false;
-
- stopRecording.current();
};
return {