|
7 | 7 | } from "@t3tools/client-runtime/state/runtime"; |
8 | 8 | import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings"; |
9 | 9 | import { ChevronDownIcon, PlusIcon } from "lucide-react"; |
10 | | -import { useCallback, useMemo, useState } from "react"; |
| 10 | +import { useState } from "react"; |
11 | 11 | import { useT3ProjectFileState } from "../../hooks/useT3ProjectFileScripts"; |
12 | 12 | import { useEnvironments } from "../../state/environments"; |
13 | 13 | import { |
@@ -84,43 +84,36 @@ export function ProjectActionsSettings() { |
84 | 84 | representativeMember?.environmentId ?? EnvironmentId.make("none"), |
85 | 85 | representativeMember?.workspaceRoot ?? null, |
86 | 86 | ); |
87 | | - const importableScripts = useMemo( |
88 | | - () => |
89 | | - t3File.scripts.filter( |
90 | | - (fileScript) => |
91 | | - !scripts.some( |
92 | | - (script) => |
93 | | - script.command === fileScript.command || |
94 | | - script.name.toLowerCase() === fileScript.name.toLowerCase(), |
95 | | - ), |
| 87 | + const importableScripts = t3File.scripts.filter( |
| 88 | + (fileScript) => |
| 89 | + !scripts.some( |
| 90 | + (script) => |
| 91 | + script.command === fileScript.command || |
| 92 | + script.name.toLowerCase() === fileScript.name.toLowerCase(), |
96 | 93 | ), |
97 | | - [scripts, t3File.scripts], |
98 | | - ); |
99 | | - const importFileScript = useCallback( |
100 | | - async (fileScript: T3ProjectFileScript) => { |
101 | | - const payload: NewProjectScriptInput = { |
102 | | - name: fileScript.name, |
103 | | - command: fileScript.command, |
104 | | - icon: fileScript.icon ?? "play", |
105 | | - runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false, |
106 | | - waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false, |
107 | | - runOnSettle: fileScript.runOnSettle ?? false, |
108 | | - keybinding: null, |
109 | | - previewUrl: fileScript.previewUrl ?? null, |
110 | | - autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false, |
111 | | - }; |
112 | | - const result = await submit(null, payload); |
113 | | - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { |
114 | | - const error = squashAtomCommandFailure(result); |
115 | | - setRequest({ |
116 | | - scriptId: null, |
117 | | - initial: payload, |
118 | | - error: error instanceof Error ? error.message : "Failed to import action.", |
119 | | - }); |
120 | | - } |
121 | | - }, |
122 | | - [submit], |
123 | 94 | ); |
| 95 | + const importFileScript = async (fileScript: T3ProjectFileScript) => { |
| 96 | + const payload: NewProjectScriptInput = { |
| 97 | + name: fileScript.name, |
| 98 | + command: fileScript.command, |
| 99 | + icon: fileScript.icon ?? "play", |
| 100 | + runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false, |
| 101 | + waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false, |
| 102 | + runOnSettle: fileScript.runOnSettle ?? false, |
| 103 | + keybinding: null, |
| 104 | + previewUrl: fileScript.previewUrl ?? null, |
| 105 | + autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false, |
| 106 | + }; |
| 107 | + const result = await submit(null, payload); |
| 108 | + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { |
| 109 | + const error = squashAtomCommandFailure(result); |
| 110 | + setRequest({ |
| 111 | + scriptId: null, |
| 112 | + initial: payload, |
| 113 | + error: error instanceof Error ? error.message : "Failed to import action.", |
| 114 | + }); |
| 115 | + } |
| 116 | + }; |
124 | 117 |
|
125 | 118 | return ( |
126 | 119 | <SettingsSection id="project-actions" title="Actions"> |
|
0 commit comments