44 type EnvironmentId ,
55 type ProjectScript ,
66 type T3ProjectFileScript ,
7- type ResolvedKeybindingsConfig ,
87} from "@t3tools/contracts" ;
98import { useAtomValue } from "@effect/atom-react" ;
109import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings" ;
@@ -14,7 +13,7 @@ import {
1413} from "@t3tools/client-runtime/state/runtime" ;
1514import { projectScriptMenuLabel } from "@t3tools/shared/projectScripts" ;
1615import { ChevronDownIcon , DownloadIcon , PlusIcon , SettingsIcon , WrenchIcon } from "lucide-react" ;
17- import React , { useCallback , useMemo , useState } from "react" ;
16+ import React , { useState } from "react" ;
1817
1918import { commandForProjectScript , primaryProjectScript } from "~/projectScripts" ;
2019import { shortcutLabelForCommand } from "~/keybindings" ;
@@ -105,24 +104,16 @@ export default function ProjectScriptsControl({
105104 }
106105 const [ editorRequest , setEditorRequest ] = useState < ProjectScriptEditorRequest | null > ( null ) ;
107106
108- const primaryScript = useMemo ( ( ) => {
109- if ( preferredScriptId ) {
110- const preferred = scripts . find ( ( script ) => script . id === preferredScriptId ) ;
111- if ( preferred ) return preferred ;
112- }
113- return primaryProjectScript ( scripts ) ;
114- } , [ preferredScriptId , scripts ] ) ;
115- const importableScripts = useMemo (
116- ( ) =>
117- fileScripts . filter (
118- ( fileScript ) =>
119- ! scripts . some (
120- ( script ) =>
121- script . command === fileScript . command ||
122- script . name . toLowerCase ( ) === fileScript . name . toLowerCase ( ) ,
123- ) ,
107+ const primaryScript =
108+ ( preferredScriptId ? scripts . find ( ( script ) => script . id === preferredScriptId ) : undefined ) ??
109+ primaryProjectScript ( scripts ) ;
110+ const importableScripts = fileScripts . filter (
111+ ( fileScript ) =>
112+ ! scripts . some (
113+ ( script ) =>
114+ script . command === fileScript . command ||
115+ script . name . toLowerCase ( ) === fileScript . name . toLowerCase ( ) ,
124116 ) ,
125- [ fileScripts , scripts ] ,
126117 ) ;
127118
128119 const openAddDialog = ( ) => {
@@ -135,11 +126,8 @@ export default function ProjectScriptsControl({
135126 setEditorRequest ( editorRequestForScript ( script , keybindings ) ) ;
136127 } ;
137128
138- const submitScript = useCallback (
139- ( scriptId : string | null , input : NewProjectScriptInput ) =>
140- scriptId === null ? onAddScript ( input ) : onUpdateScript ( scriptId , input ) ,
141- [ onAddScript , onUpdateScript ] ,
142- ) ;
129+ const submitScript = ( scriptId : string | null , input : NewProjectScriptInput ) =>
130+ scriptId === null ? onAddScript ( input ) : onUpdateScript ( scriptId , input ) ;
143131
144132 const importFileScript = async ( fileScript : T3ProjectFileScript ) => {
145133 const payload : NewProjectScriptInput = {
0 commit comments