Skip to content
TypeScript

perf(web): project actions settings compile without manual memoization (#20602)

Julius Marmingec36880ea6722
diff --git a/apps/web/src/components/settings/ProjectActionsSettings.tsx b/apps/web/src/components/settings/ProjectActionsSettings.tsx
index 658644eccc4..e212f2ed985 100644
--- a/apps/web/src/components/settings/ProjectActionsSettings.tsx
+++ b/apps/web/src/components/settings/ProjectActionsSettings.tsx
@@ -7,7 +7,7 @@ import {
} from "@t3tools/client-runtime/state/runtime";
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
import { ChevronDownIcon, PlusIcon } from "lucide-react";
-import { useCallback, useMemo, useState } from "react";
+import { useState } from "react";
import { useT3ProjectFileState } from "../../hooks/useT3ProjectFileScripts";
import { useEnvironments } from "../../state/environments";
import {
@@ -84,43 +84,36 @@ export function ProjectActionsSettings() {
representativeMember?.environmentId ?? EnvironmentId.make("none"),
representativeMember?.workspaceRoot ?? null,
);
- const importableScripts = useMemo(
- () =>
- t3File.scripts.filter(
- (fileScript) =>
- !scripts.some(
- (script) =>
- script.command === fileScript.command ||
- script.name.toLowerCase() === fileScript.name.toLowerCase(),
- ),
+ const importableScripts = t3File.scripts.filter(
+ (fileScript) =>
+ !scripts.some(
+ (script) =>
+ script.command === fileScript.command ||
+ script.name.toLowerCase() === fileScript.name.toLowerCase(),
),
- [scripts, t3File.scripts],
- );
- const importFileScript = useCallback(
- async (fileScript: T3ProjectFileScript) => {
- const payload: NewProjectScriptInput = {
- name: fileScript.name,
- command: fileScript.command,
- icon: fileScript.icon ?? "play",
- runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
- waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
- runOnSettle: fileScript.runOnSettle ?? false,
- keybinding: null,
- previewUrl: fileScript.previewUrl ?? null,
- autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
- };
- const result = await submit(null, payload);
- if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
- const error = squashAtomCommandFailure(result);
- setRequest({
- scriptId: null,
- initial: payload,
- error: error instanceof Error ? error.message : "Failed to import action.",
- });
- }
- },
- [submit],
);
+ const importFileScript = async (fileScript: T3ProjectFileScript) => {
+ const payload: NewProjectScriptInput = {
+ name: fileScript.name,
+ command: fileScript.command,
+ icon: fileScript.icon ?? "play",
+ runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
+ waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
+ runOnSettle: fileScript.runOnSettle ?? false,
+ keybinding: null,
+ previewUrl: fileScript.previewUrl ?? null,
+ autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
+ };
+ const result = await submit(null, payload);
+ if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
+ const error = squashAtomCommandFailure(result);
+ setRequest({
+ scriptId: null,
+ initial: payload,
+ error: error instanceof Error ? error.message : "Failed to import action.",
+ });
+ }
+ };
return (
<SettingsSection id="project-actions" title="Actions">