fix: auto-finalize duration bug, restore cancelRecording, and add i18n for pause tooltips
This commit is contained in:
@@ -459,7 +459,7 @@ export function LaunchWindow() {
|
||||
</button>
|
||||
|
||||
{recording && (
|
||||
<Tooltip content={paused ? "Resume recording" : "Pause recording"}>
|
||||
<Tooltip content={paused ? t("tooltips.resumeRecording") : t("tooltips.pauseRecording")}>
|
||||
<button
|
||||
className={`${hudIconBtnClasses} ${styles.electronNoDrag}`}
|
||||
onClick={togglePaused}
|
||||
|
||||
@@ -113,9 +113,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
|
||||
|
||||
const getRecordingDurationMs = useCallback(() => {
|
||||
const segmentDuration =
|
||||
screenRecorder.current?.recorder.state === "recording" && segmentStartedAt.current
|
||||
? Date.now() - segmentStartedAt.current
|
||||
: 0;
|
||||
segmentStartedAt.current === null ? 0 : Date.now() - segmentStartedAt.current;
|
||||
return accumulatedDurationMs.current + segmentDuration;
|
||||
}, []);
|
||||
|
||||
@@ -700,6 +698,17 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
|
||||
return () => window.clearInterval(interval);
|
||||
}, [getRecordingDurationMs, paused, recording]);
|
||||
|
||||
const cancelRecording = () => {
|
||||
const activeScreenRecorder = screenRecorder.current;
|
||||
if (!activeScreenRecorder || activeScreenRecorder.recorder.state !== "recording") return;
|
||||
|
||||
const activeRecordingId = recordingId.current;
|
||||
discardRecordingId.current = activeRecordingId;
|
||||
allowAutoFinalize.current = false;
|
||||
|
||||
stopRecording.current();
|
||||
};
|
||||
|
||||
return {
|
||||
recording,
|
||||
paused,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
"closeApp": "Close App",
|
||||
"restartRecording": "Restart recording",
|
||||
"cancelRecording": "Cancel recording",
|
||||
"pauseRecording": "Pause recording",
|
||||
"resumeRecording": "Resume recording",
|
||||
"openVideoFile": "Open video file",
|
||||
"openProject": "Open project"
|
||||
},
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
"closeApp": "Cerrar aplicación",
|
||||
"restartRecording": "Reiniciar grabación",
|
||||
"cancelRecording": "Cancelar grabación",
|
||||
"pauseRecording": "Pausar grabación",
|
||||
"resumeRecording": "Reanudar grabación",
|
||||
"openVideoFile": "Abrir archivo de video",
|
||||
"openProject": "Abrir proyecto"
|
||||
},
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
"closeApp": "关闭应用",
|
||||
"restartRecording": "重新开始录制",
|
||||
"cancelRecording": "取消录制",
|
||||
"pauseRecording": "暂停录制",
|
||||
"resumeRecording": "继续录制",
|
||||
"openVideoFile": "打开视频文件",
|
||||
"openProject": "打开项目"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user