11import { useEffect , useState , useRef } from "react" ;
22import { Source , UploadLink , baseUrl , isProd } from "../utils" ;
3- import { Video } from "lucide-react" ;
3+ import { StopCircle , Video } from "lucide-react" ;
44import { captureException } from "@sentry/react" ;
55import { Progress } from "./ui/progress" ;
66
@@ -22,6 +22,7 @@ export function Recorder({
2222 const [ audioStream , setAudioStream ] = useState < MediaStream | null > ( null ) ;
2323 const [ progress , setProgress ] = useState ( 13 ) ;
2424 const [ justStarted , setJustStarted ] = useState ( false ) ;
25+ const [ isHoveringStopRecording , setIsHoveringStopRecording ] = useState ( false ) ;
2526
2627 const uploadFile = async (
2728 uploadFilePath : string ,
@@ -48,7 +49,7 @@ export function Recorder({
4849 }
4950 await window . electron . uploadVideo ( uploadFilePath , uploadLink ) ;
5051 const uploadUrl = `${ baseUrl } /view/${ uploadId } ` ;
51- if ( openInBrowser ) await window . electron . openInBrowser ( uploadUrl ) ;
52+ if ( openInBrowser ) await window . electron . openInBrowser ( uploadUrl ) ;
5253 } catch ( error ) {
5354 console . error ( "Failed to upload file:" , error ) ;
5455 captureException ( error , {
@@ -365,7 +366,11 @@ export function Recorder({
365366 }
366367 } ;
367368
368- const stopRecording = ( ) => {
369+ const stopRecording = async ( ) => {
370+ await window . electron . stopRecording ( ) ;
371+ } ;
372+
373+ const stopRecordingStreams = ( ) => {
369374 try {
370375 setIsRecording ( false ) ;
371376
@@ -415,25 +420,40 @@ export function Recorder({
415420 // @ts -ignore
416421 window . electron . on ( "finished-recording" , ( status : boolean ) => {
417422 if ( status ) {
418- stopRecording ( ) ;
423+ stopRecordingStreams ( ) ;
419424 }
420425 } ) ;
421426
422427 return (
423428 < div >
424429 < button
425- onClick = { startRecording }
426- disabled = { isRecording }
430+ onClick = { isRecording ? stopRecording : startRecording }
427431 className = { `w-full h-10 group relative justify-center gap-2 transition-all duration-300 ease-out hover:ring-2 hover:ring-primary hover:ring-offset-2 bg-sky-700 text-white hover:bg-sky-900 border border-transparent hover:border-sky-900 focus:border-sky-500 focus:ring focus:ring-sky-500 rounded-lg ${
428432 isRecording &&
429433 "bg-red-500 hover:bg-red-600 focus:border-red-400 focus:ring-red-400"
430434 } `}
431435 >
432436 { isRecording ? (
433- < div className = "flex items-center" >
434- < div className = "animate-ping absolute inline-flex h-3 w-3 rounded-full bg-red-400 opacity-75 ml-3" > </ div >
435- < div className = "relative inline-flex rounded-full h-3 w-3 bg-red-400 ml-3" > </ div >
436- < span className = "text-md ml-3" > Recording...</ span >
437+ < div
438+ className = "flex items-center justify-between"
439+ onMouseEnter = { ( ) => setIsHoveringStopRecording ( true ) }
440+ onMouseLeave = { ( ) => setIsHoveringStopRecording ( false ) }
441+ >
442+ < div className = "flex items-center" >
443+ { isHoveringStopRecording ? (
444+ < StopCircle className = { "ml-2 h-4 w-4 " } />
445+ ) : (
446+ < >
447+ < div className = "animate-ping absolute inline-flex h-3 w-3 rounded-full bg-red-400 opacity-75 ml-3" > </ div >
448+ < div className = "relative inline-flex rounded-full h-3 w-3 bg-red-400 ml-3" > </ div >
449+ </ >
450+ ) }
451+ { isHoveringStopRecording ? (
452+ < span className = "text-md ml-3" > Stop Recording</ span >
453+ ) : (
454+ < span className = "text-md ml-3" > Recording...</ span >
455+ ) }
456+ </ div >
437457 </ div >
438458 ) : justStarted ? (
439459 < div className = "flex items-center justify-center" >
@@ -452,4 +472,4 @@ export function Recorder({
452472 ) }
453473 </ div >
454474 ) ;
455- }
475+ }
0 commit comments