fix: pause button while recording should stop recoding

This commit is contained in:
Xiaohan-Tian
2026-05-02 23:02:37 -07:00
parent 9f536d9687
commit 7a6e7558ce
5 changed files with 71 additions and 13 deletions
+5 -5
View File
@@ -14,7 +14,7 @@ import { KGMidiRegion } from '../core/region/KGMidiRegion';
* Handles keyboard shortcuts defined in the configuration
*/
export const useGlobalKeyboardHandler = () => {
const { undo, redo, setStatus, isPlaying, startPlaying, stopPlaying, toggleLoop, projectName, savedProjectName, setSavedProjectName, setProjectName, isRecording, startRecording, stopRecording, activeRegionId, selectedRegionIds, setActiveRegionId, setShowPianoRoll } = useProjectStore();
const { undo, redo, setStatus, isPlaying, startPlaying, stopTransport, toggleLoop, projectName, savedProjectName, setSavedProjectName, setProjectName, isRecording, startRecording, stopRecording, activeRegionId, selectedRegionIds, setActiveRegionId, setShowPianoRoll } = useProjectStore();
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
@@ -134,8 +134,8 @@ export const useGlobalKeyboardHandler = () => {
startPlaying();
setStatus('Playback started');
} else {
stopPlaying();
setStatus('Playback stopped');
stopTransport();
setStatus(isRecording ? 'Recording stopped — notes committed' : 'Playback stopped');
}
} catch (error) {
console.error('Play/pause failed:', error);
@@ -216,5 +216,5 @@ export const useGlobalKeyboardHandler = () => {
return () => {
document.removeEventListener('keydown', handleKeyDown, { capture: true });
};
}, [undo, redo, setStatus, isPlaying, startPlaying, stopPlaying, toggleLoop, projectName, isRecording, startRecording, stopRecording, activeRegionId, selectedRegionIds, setActiveRegionId, setShowPianoRoll]); // Include dependencies for store actions
};
}, [undo, redo, setStatus, isPlaying, startPlaying, stopTransport, toggleLoop, projectName, savedProjectName, setSavedProjectName, setProjectName, isRecording, startRecording, stopRecording, activeRegionId, selectedRegionIds, setActiveRegionId, setShowPianoRoll]); // Include dependencies for store actions
};