mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56: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 fontSize = useChatStore((state) => state.config.fontSize);
|
||||||
|
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const messageInputRefs = useRef<HTMLDivElement[]>([]);
|
|
||||||
const [userInput, setUserInput] = useState("");
|
const [userInput, setUserInput] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { submitKey, shouldSubmit } = useSubmitHandler();
|
const { submitKey, shouldSubmit } = useSubmitHandler();
|
||||||
@ -315,7 +314,6 @@ export function Chat(props: {
|
|||||||
content: "……",
|
content: "……",
|
||||||
date: new Date().toLocaleString(),
|
date: new Date().toLocaleString(),
|
||||||
preview: true,
|
preview: true,
|
||||||
isEditing: false,
|
|
||||||
editingText: "",
|
editingText: "",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -329,7 +327,6 @@ export function Chat(props: {
|
|||||||
content: userInput,
|
content: userInput,
|
||||||
date: new Date().toLocaleString(),
|
date: new Date().toLocaleString(),
|
||||||
preview: true,
|
preview: true,
|
||||||
isEditing: false,
|
|
||||||
editingText: "",
|
editingText: "",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -471,7 +468,7 @@ export function Chat(props: {
|
|||||||
onContextMenu={(e) => onRightClick(e, message)}
|
onContextMenu={(e) => onRightClick(e, message)}
|
||||||
onDoubleClickCapture={() => setUserInput(message.content)}
|
onDoubleClickCapture={() => setUserInput(message.content)}
|
||||||
>
|
>
|
||||||
{message.isEditing ? (
|
{message.editingText ? (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
@ -489,7 +486,7 @@ export function Chat(props: {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</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-actions"]}>
|
||||||
<div
|
<div
|
||||||
className={styles["chat-message-bottom-action"]}
|
className={styles["chat-message-bottom-action"]}
|
||||||
@ -506,7 +503,7 @@ export function Chat(props: {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{isUser && message.isEditing && (
|
{isUser && message.editingText && (
|
||||||
<div style={{display: "flex"}}>
|
<div style={{display: "flex"}}>
|
||||||
<div
|
<div
|
||||||
className={styles["chat-message-action-edit"]}
|
className={styles["chat-message-action-edit"]}
|
||||||
|
@ -174,7 +174,7 @@ export async function requestWithPrompt(messages: Message[], prompt: string) {
|
|||||||
role: "user",
|
role: "user",
|
||||||
content: prompt,
|
content: prompt,
|
||||||
date: new Date().toLocaleString(),
|
date: new Date().toLocaleString(),
|
||||||
isEditing: false
|
editingText: ""
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import Locale from "../locales";
|
|||||||
export type Message = ChatCompletionResponseMessage & {
|
export type Message = ChatCompletionResponseMessage & {
|
||||||
date: string;
|
date: string;
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
isEditing: boolean;
|
|
||||||
editingText: string;
|
editingText: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ function createEmptySession(): ChatSession {
|
|||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: Locale.Store.BotHello,
|
content: Locale.Store.BotHello,
|
||||||
date: createDate,
|
date: createDate,
|
||||||
isEditing: false
|
editingText: ""
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
stat: {
|
stat: {
|
||||||
@ -304,7 +303,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
},
|
},
|
||||||
|
|
||||||
onUserEdit(message) {
|
onUserEdit(message) {
|
||||||
message.isEditing = true;
|
|
||||||
message.editingText = message.content;
|
message.editingText = message.content;
|
||||||
set(() => ({}))
|
set(() => ({}))
|
||||||
},
|
},
|
||||||
@ -317,7 +315,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
},
|
},
|
||||||
|
|
||||||
onCancelEdit(message) {
|
onCancelEdit(message) {
|
||||||
message.isEditing = false;
|
|
||||||
message.editingText = "";
|
message.editingText = "";
|
||||||
set(() => ({}))
|
set(() => ({}))
|
||||||
},
|
},
|
||||||
@ -326,7 +323,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
role: "user",
|
role: "user",
|
||||||
content,
|
content,
|
||||||
date: new Date().toLocaleString(),
|
date: new Date().toLocaleString(),
|
||||||
isEditing: false,
|
|
||||||
editingText: ""
|
editingText: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -335,7 +331,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
role: "assistant",
|
role: "assistant",
|
||||||
date: new Date().toLocaleString(),
|
date: new Date().toLocaleString(),
|
||||||
streaming: true,
|
streaming: true,
|
||||||
isEditing: false,
|
|
||||||
editingText: ""
|
editingText: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -472,7 +467,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
role: "system",
|
role: "system",
|
||||||
content: Locale.Store.Prompt.Summarize,
|
content: Locale.Store.Prompt.Summarize,
|
||||||
date: "",
|
date: "",
|
||||||
isEditing: false,
|
|
||||||
editingText: ""
|
editingText: ""
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user