@@ -12,8 +12,6 @@ import { NoteType } from '../../../types/note.types.ts';
1212
1313import { CreateNoteModal } from './CreateNoteModal/CreateNoteModal.tsx' ;
1414
15- import { ButtonHandler } from './CreateNoteBar.ts' ;
16-
1715import './CreateNoteBar.css'
1816
1917interface CreateNoteBarProps {
@@ -62,6 +60,23 @@ export const CreateNoteBar: FC<CreateNoteBarProps> = ({ isVisible }) => {
6260 deleteTranscription ( ) ;
6361 }
6462
63+ const handleToggleRecording = async ( ) => {
64+ if ( ! hasMicPermissions && ! isMicDeniedPopupVisible )
65+ setIsMicDeniedPopupVisible ( true ) ;
66+
67+ if ( isRecording ) {
68+ if ( isTranscribing )
69+ stopTranscribing ( ) ;
70+
71+ return stopRecording ( ) ;
72+ }
73+
74+ await startRecording ( MAX_AUDIO_RECORD_DURATION ) ;
75+
76+ if ( hasSpeechRecognitionSupport && ! isTranscribing && ! ! startTranscribing )
77+ startTranscribing ( ) ;
78+ }
79+
6580 return (
6681 < >
6782 < CreateNoteModal
@@ -85,20 +100,7 @@ export const CreateNoteBar: FC<CreateNoteBarProps> = ({ isVisible }) => {
85100 < button className = 'add-note-button' onClick = { ( ) => { setNoteType ( 'text' ) ; setModalOpen ( true ) } } >
86101 < FiFilePlus />
87102 </ button >
88- < div className = "record-note-button-container" onClick = {
89- async ( ) => {
90- ButtonHandler . recordButtonOnClick (
91- startRecording , stopRecording ,
92- isRecording ,
93- hasMicPermissions ,
94-
95- startTranscribing , stopTranscribing ,
96- isTranscribing ,
97- hasSpeechRecognitionSupport ,
98-
99- isMicDeniedPopupVisible , setIsMicDeniedPopupVisible
100- )
101- } } >
103+ < div className = "record-note-button-container" onClick = { handleToggleRecording } >
102104 { isRecording ? (
103105 < >
104106 < BsStopFill />
0 commit comments