44 createEventListenerMap ,
55} from "@solid-primitives/event-listener" ;
66import { useSearchParams } from "@solidjs/router" ;
7- import { createQuery } from "@tanstack/solid-query" ;
7+ import { createQuery , useMutation } from "@tanstack/solid-query" ;
88import { emit } from "@tauri-apps/api/event" ;
99import { CheckMenuItem , Menu , Submenu } from "@tauri-apps/api/menu" ;
1010import * as dialog from "@tauri-apps/plugin-dialog" ;
@@ -795,6 +795,18 @@ function RecordingControls(props: {
795795 return await Menu . new ( { items : [ await countdownMenu ( ) ] } ) ;
796796 } ;
797797
798+ const startRecording = useMutation ( ( ) => ( {
799+ mutationFn : ( ) =>
800+ handleRecordingResult (
801+ commands . startRecording ( {
802+ capture_target : props . target ,
803+ mode : rawOptions . mode ,
804+ capture_system_audio : rawOptions . captureSystemAudio ,
805+ } ) ,
806+ setOptions ,
807+ ) ,
808+ } ) ) ;
809+
798810 return (
799811 < >
800812 < div class = "flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4" >
@@ -805,43 +817,48 @@ function RecordingControls(props: {
805817 < IconCapX class = "invert will-change-transform size-3 dark:invert-0" />
806818 </ div >
807819 < div
808- data-inactive = { rawOptions . mode === "instant" && ! auth . data }
809- class = "flex overflow-hidden flex-row h-11 rounded-full bg-blue-9 group"
820+ data-inactive = {
821+ ( rawOptions . mode === "instant" && ! auth . data ) ||
822+ startRecording . isPending
823+ }
824+ class = "flex overflow-hidden flex-row h-11 rounded-full bg-blue-9 text-white group data-[inactive='true']:bg-blue-8 data-[inactive='true']:text-white/80"
810825 onClick = { ( ) => {
811826 if ( rawOptions . mode === "instant" && ! auth . data ) {
812827 emit ( "start-sign-in" ) ;
813828 return ;
814829 }
830+ if ( startRecording . isPending ) return ;
815831
816- handleRecordingResult (
817- commands . startRecording ( {
818- capture_target : props . target ,
819- mode : rawOptions . mode ,
820- capture_system_audio : rawOptions . captureSystemAudio ,
821- } ) ,
822- setOptions ,
823- ) ;
832+ startRecording . mutate ( ) ;
824833 } }
825834 >
826- < div class = "flex items-center py-1 pl-4 transition-colors hover:bg-blue-10" >
835+ < div
836+ class = { cx (
837+ "flex items-center py-1 pl-4 transition-colors" ,
838+ ! startRecording . isPending && "hover:bg-blue-10" ,
839+ ) }
840+ >
827841 { rawOptions . mode === "studio" ? (
828842 < IconCapFilmCut class = "size-4" />
829843 ) : (
830844 < IconCapInstant class = "size-4" />
831845 ) }
832846 < div class = "flex flex-col mr-2 ml-3" >
833- < span class = "text-sm font-medium text-white text- nowrap" >
847+ < span class = "text-sm font-medium text-nowrap" >
834848 { rawOptions . mode === "instant" && ! auth . data
835849 ? "Sign In To Use"
836850 : "Start Recording" }
837851 </ span >
838- < span class = "text-xs flex items-center text-nowrap gap-1 transition-opacity duration-200 text-white font-light -mt-0.5 opacity-90" >
852+ < span class = "text-xs flex items-center text-nowrap gap-1 transition-opacity duration-200 font-light -mt-0.5 opacity-90" >
839853 { `${ capitalize ( rawOptions . mode ) } Mode` }
840854 </ span >
841855 </ div >
842856 </ div >
843857 < div
844- class = "pl-2.5 group-hover:bg-blue-10 transition-colors pr-3 py-1.5 flex items-center"
858+ class = { cx (
859+ "pl-2.5 transition-colors pr-3 py-1.5 flex items-center" ,
860+ ! startRecording . isPending && "group-hover:bg-blue-10" ,
861+ ) }
845862 onClick = { ( e ) => {
846863 e . stopPropagation ( ) ;
847864 menuModes ( ) . then ( ( menu ) => menu . popup ( ) ) ;
0 commit comments