@@ -10,7 +10,6 @@ import {
1010} from "@t3tools/contracts" ;
1111import * as Cause from "effect/Cause" ;
1212import { AsyncResult } from "effect/reactivity" ;
13- import { useCallback } from "react" ;
1413
1514import { readEnvironmentScope } from "./session" ;
1615import { useAtomCommand } from "./use-atom-command" ;
@@ -23,20 +22,17 @@ export function useOrchestrationCommand<W extends { readonly environmentId: Envi
2322 options ?: string | AtomCommandOptions ,
2423) : ( value : W ) => Promise < AtomCommandResult < A , E | EnvironmentAuthorizationError > > {
2524 const run = useAtomCommand ( command , options ) ;
26- return useCallback (
27- async ( value : W ) : Promise < AtomCommandResult < A , E | EnvironmentAuthorizationError > > => {
28- if ( ! readEnvironmentScope ( value . environmentId , AuthOrchestrationOperateScope ) ) {
29- return AsyncResult . failure (
30- Cause . fail (
31- new EnvironmentAuthorizationError ( {
32- requiredScope : AuthOrchestrationOperateScope ,
33- message : ORCHESTRATION_OPERATE_DENIED_MESSAGE ,
34- } ) ,
35- ) ,
36- ) ;
37- }
38- return run ( value ) ;
39- } ,
40- [ run ] ,
41- ) ;
25+ return async ( value : W ) : Promise < AtomCommandResult < A , E | EnvironmentAuthorizationError > > => {
26+ if ( ! readEnvironmentScope ( value . environmentId , AuthOrchestrationOperateScope ) ) {
27+ return AsyncResult . failure (
28+ Cause . fail (
29+ new EnvironmentAuthorizationError ( {
30+ requiredScope : AuthOrchestrationOperateScope ,
31+ message : ORCHESTRATION_OPERATE_DENIED_MESSAGE ,
32+ } ) ,
33+ ) ,
34+ ) ;
35+ }
36+ return run ( value ) ;
37+ } ;
4238}
0 commit comments