From 2c1d7a6b7135a4ad98db65a74192e0533c0efb3c Mon Sep 17 00:00:00 2001 From: Dustin Healy Date: Sun, 7 Sep 2025 01:59:53 -0700 Subject: [PATCH] refactor: remove unnecessary onFileChange, just handle onSave stuff in onFilesChange --- .../src/components/Prompts/Groups/CreatePromptForm.tsx | 1 - client/src/components/Prompts/PromptFile.tsx | 7 ------- client/src/components/Prompts/PromptFiles.tsx | 3 --- client/src/components/Prompts/PromptForm.tsx | 10 +++++----- .../src/components/Prompts/PromptVariablesAndFiles.tsx | 3 --- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/client/src/components/Prompts/Groups/CreatePromptForm.tsx b/client/src/components/Prompts/Groups/CreatePromptForm.tsx index 1fbbe7ab26..2a618923fd 100644 --- a/client/src/components/Prompts/Groups/CreatePromptForm.tsx +++ b/client/src/components/Prompts/Groups/CreatePromptForm.tsx @@ -184,7 +184,6 @@ const CreatePromptForm = ({ onFilesChange={setFiles} handleFileChange={handleFileChange} disabled={isSubmitting} - onFileChange={() => {}} /> methods.setValue('oneliner', value)} diff --git a/client/src/components/Prompts/PromptFile.tsx b/client/src/components/Prompts/PromptFile.tsx index 37937a2507..f750e77ce1 100644 --- a/client/src/components/Prompts/PromptFile.tsx +++ b/client/src/components/Prompts/PromptFile.tsx @@ -13,7 +13,6 @@ export default function PromptFile({ fileFilter, isRTL = false, Wrapper, - onFileChange, }: { files: Map | undefined; abortUpload?: () => void; @@ -22,7 +21,6 @@ export default function PromptFile({ fileFilter?: (file: ExtendedFile) => boolean; isRTL?: boolean; Wrapper?: React.FC<{ children: React.ReactNode }>; - onFileChange?: (files: ExtendedFile[]) => void; }) { const localize = useLocalize(); const { showToast } = useToastContext(); @@ -103,11 +101,6 @@ export default function PromptFile({ if (file.temp_file_id) { updatedFiles.delete(file.temp_file_id); } - - // Call onFileChange with the updated files array - const updatedFilesArray = Array.from(updatedFiles.values()); - onFileChange?.(updatedFilesArray); - return updatedFiles; }); }; diff --git a/client/src/components/Prompts/PromptFiles.tsx b/client/src/components/Prompts/PromptFiles.tsx index 520717e6f1..75ade75756 100644 --- a/client/src/components/Prompts/PromptFiles.tsx +++ b/client/src/components/Prompts/PromptFiles.tsx @@ -12,13 +12,11 @@ const PromptFiles = ({ onFilesChange, handleFileChange, disabled, - onFileChange, }: { files: ExtendedFile[]; onFilesChange?: (files: ExtendedFile[]) => void; handleFileChange?: (event: React.ChangeEvent, toolResource?: string) => void; disabled?: boolean; - onFileChange?: (files: ExtendedFile[]) => void; }) => { const localize = useLocalize(); @@ -65,7 +63,6 @@ const PromptFiles = ({ onFilesChange?.(newFiles); }} setFilesLoading={() => {}} - onFileChange={onFileChange} Wrapper={({ children }) =>
{children}
} /> diff --git a/client/src/components/Prompts/PromptForm.tsx b/client/src/components/Prompts/PromptForm.tsx index 91e770abe3..8ef3137659 100644 --- a/client/src/components/Prompts/PromptForm.tsx +++ b/client/src/components/Prompts/PromptForm.tsx @@ -541,15 +541,15 @@ const PromptForm = () => { { + onFilesChange={(files) => { + setFiles(files); if (canEdit && selectedPrompt) { const currentPromptText = getValues('prompt'); - onSave(currentPromptText, updatedFiles); + onSave(currentPromptText, files); } }} + handleFileChange={handleFileChange} + disabled={!canEdit} /> , toolResource?: string) => void; disabled?: boolean; showVariablesInfo?: boolean; - onFileChange?: (files: ExtendedFile[]) => void; } const PromptVariablesAndFiles: React.FC = ({ @@ -20,7 +19,6 @@ const PromptVariablesAndFiles: React.FC = ({ handleFileChange, disabled, showVariablesInfo = true, - onFileChange, }) => { return (
@@ -36,7 +34,6 @@ const PromptVariablesAndFiles: React.FC = ({ onFilesChange={onFilesChange} handleFileChange={handleFileChange} disabled={disabled} - onFileChange={onFileChange} />