From 556e3ce93548a915910ad74765a4433e540d4569 Mon Sep 17 00:00:00 2001 From: RugerMc <550279039@qq.com> Date: Sat, 1 Apr 2023 22:46:15 +0800 Subject: [PATCH] opt: remove editing state --- app/components/home.tsx | 9 +++------ app/requests.ts | 2 +- app/store/app.ts | 8 +------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 90eb32d63..1e5b56666 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -190,7 +190,6 @@ export function Chat(props: { const fontSize = useChatStore((state) => state.config.fontSize); const inputRef = useRef(null); - const messageInputRefs = useRef([]); const [userInput, setUserInput] = useState(""); const [isLoading, setIsLoading] = useState(false); const { submitKey, shouldSubmit } = useSubmitHandler(); @@ -315,7 +314,6 @@ export function Chat(props: { content: "……", date: new Date().toLocaleString(), preview: true, - isEditing: false, editingText: "", }, ] @@ -329,7 +327,6 @@ export function Chat(props: { content: userInput, date: new Date().toLocaleString(), preview: true, - isEditing: false, editingText: "", }, ] @@ -471,7 +468,7 @@ export function Chat(props: { onContextMenu={(e) => onRightClick(e, message)} onDoubleClickCapture={() => setUserInput(message.content)} > - {message.isEditing ? ( + {message.editingText ? (
{ @@ -489,7 +486,7 @@ export function Chat(props: {
)} - {isUser && !message.preview && !message.isEditing && ( + {isUser && !message.preview && !message.editingText && (
)} - {isUser && message.isEditing && ( + {isUser && message.editingText && (
()( }, onUserEdit(message) { - message.isEditing = true; message.editingText = message.content; set(() => ({})) }, @@ -317,7 +315,6 @@ export const useChatStore = create()( }, onCancelEdit(message) { - message.isEditing = false; message.editingText = ""; set(() => ({})) }, @@ -326,7 +323,6 @@ export const useChatStore = create()( role: "user", content, date: new Date().toLocaleString(), - isEditing: false, editingText: "" }; @@ -335,7 +331,6 @@ export const useChatStore = create()( role: "assistant", date: new Date().toLocaleString(), streaming: true, - isEditing: false, editingText: "" }; @@ -472,7 +467,6 @@ export const useChatStore = create()( role: "system", content: Locale.Store.Prompt.Summarize, date: "", - isEditing: false, editingText: "" }), {