mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 15:46:39 +08:00
opt: remove editing state
This commit is contained in:
parent
232630d005
commit
556e3ce935
@ -190,7 +190,6 @@ export function Chat(props: {
|
||||
const fontSize = useChatStore((state) => state.config.fontSize);
|
||||
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
const messageInputRefs = useRef<HTMLDivElement[]>([]);
|
||||
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 ? (
|
||||
<div
|
||||
key={i}
|
||||
onInput={(e) => {
|
||||
@ -489,7 +486,7 @@ export function Chat(props: {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{isUser && !message.preview && !message.isEditing && (
|
||||
{isUser && !message.preview && !message.editingText && (
|
||||
<div className={styles["chat-message-bottom-actions"]}>
|
||||
<div
|
||||
className={styles["chat-message-bottom-action"]}
|
||||
@ -506,7 +503,7 @@ export function Chat(props: {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isUser && message.isEditing && (
|
||||
{isUser && message.editingText && (
|
||||
<div style={{display: "flex"}}>
|
||||
<div
|
||||
className={styles["chat-message-action-edit"]}
|
||||
|
@ -174,7 +174,7 @@ export async function requestWithPrompt(messages: Message[], prompt: string) {
|
||||
role: "user",
|
||||
content: prompt,
|
||||
date: new Date().toLocaleString(),
|
||||
isEditing: false
|
||||
editingText: ""
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -14,7 +14,6 @@ import Locale from "../locales";
|
||||
export type Message = ChatCompletionResponseMessage & {
|
||||
date: string;
|
||||
streaming?: boolean;
|
||||
isEditing: boolean;
|
||||
editingText: string;
|
||||
};
|
||||
|
||||
@ -171,7 +170,7 @@ function createEmptySession(): ChatSession {
|
||||
role: "assistant",
|
||||
content: Locale.Store.BotHello,
|
||||
date: createDate,
|
||||
isEditing: false
|
||||
editingText: ""
|
||||
},
|
||||
],
|
||||
stat: {
|
||||
@ -304,7 +303,6 @@ export const useChatStore = create<ChatStore>()(
|
||||
},
|
||||
|
||||
onUserEdit(message) {
|
||||
message.isEditing = true;
|
||||
message.editingText = message.content;
|
||||
set(() => ({}))
|
||||
},
|
||||
@ -317,7 +315,6 @@ export const useChatStore = create<ChatStore>()(
|
||||
},
|
||||
|
||||
onCancelEdit(message) {
|
||||
message.isEditing = false;
|
||||
message.editingText = "";
|
||||
set(() => ({}))
|
||||
},
|
||||
@ -326,7 +323,6 @@ export const useChatStore = create<ChatStore>()(
|
||||
role: "user",
|
||||
content,
|
||||
date: new Date().toLocaleString(),
|
||||
isEditing: false,
|
||||
editingText: ""
|
||||
};
|
||||
|
||||
@ -335,7 +331,6 @@ export const useChatStore = create<ChatStore>()(
|
||||
role: "assistant",
|
||||
date: new Date().toLocaleString(),
|
||||
streaming: true,
|
||||
isEditing: false,
|
||||
editingText: ""
|
||||
};
|
||||
|
||||
@ -472,7 +467,6 @@ export const useChatStore = create<ChatStore>()(
|
||||
role: "system",
|
||||
content: Locale.Store.Prompt.Summarize,
|
||||
date: "",
|
||||
isEditing: false,
|
||||
editingText: ""
|
||||
}),
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user