Skip to content
TypeScript

perf(web): useOrchestrationCommand compiles without manual memoization (#20576)

Julius Marmingedd1ab3f059f1
diff --git a/apps/web/src/state/use-orchestration-command.ts b/apps/web/src/state/use-orchestration-command.ts
index 17eea2e72d1..1c801abc3c6 100644
--- a/apps/web/src/state/use-orchestration-command.ts
+++ b/apps/web/src/state/use-orchestration-command.ts
@@ -10,7 +10,6 @@ import {
} from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import { AsyncResult } from "effect/reactivity";
-import { useCallback } from "react";
import { readEnvironmentScope } from "./session";
import { useAtomCommand } from "./use-atom-command";
@@ -23,20 +22,17 @@ export function useOrchestrationCommand<W extends { readonly environmentId: Envi
options?: string | AtomCommandOptions,
): (value: W) => Promise<AtomCommandResult<A, E | EnvironmentAuthorizationError>> {
const run = useAtomCommand(command, options);
- return useCallback(
- async (value: W): Promise<AtomCommandResult<A, E | EnvironmentAuthorizationError>> => {
- if (!readEnvironmentScope(value.environmentId, AuthOrchestrationOperateScope)) {
- return AsyncResult.failure(
- Cause.fail(
- new EnvironmentAuthorizationError({
- requiredScope: AuthOrchestrationOperateScope,
- message: ORCHESTRATION_OPERATE_DENIED_MESSAGE,
- }),
- ),
- );
- }
- return run(value);
- },
- [run],
- );
+ return async (value: W): Promise<AtomCommandResult<A, E | EnvironmentAuthorizationError>> => {
+ if (!readEnvironmentScope(value.environmentId, AuthOrchestrationOperateScope)) {
+ return AsyncResult.failure(
+ Cause.fail(
+ new EnvironmentAuthorizationError({
+ requiredScope: AuthOrchestrationOperateScope,
+ message: ORCHESTRATION_OPERATE_DENIED_MESSAGE,
+ }),
+ ),
+ );
+ }
+ return run(value);
+ };
}