mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 03:26:38 +08:00
用户输入框内容会随着Session切换而切换
This commit is contained in:
parent
ef269acc20
commit
c67af258d3
@ -87,21 +87,14 @@ export function ChatItem(props: {
|
||||
}
|
||||
|
||||
export function ChatList() {
|
||||
const [
|
||||
sidebarCollapse,
|
||||
sessions,
|
||||
selectedIndex,
|
||||
selectSession,
|
||||
removeSession,
|
||||
moveSession,
|
||||
] = useChatStore((state) => [
|
||||
state.sidebarCollapse,
|
||||
state.sessions,
|
||||
state.currentSessionIndex,
|
||||
state.selectSession,
|
||||
state.removeSession,
|
||||
state.moveSession,
|
||||
]);
|
||||
const [sidebarCollapse, sessions, selectedIndex, selectSession, moveSession] =
|
||||
useChatStore((state) => [
|
||||
state.sidebarCollapse,
|
||||
state.sessions,
|
||||
state.currentSessionIndex,
|
||||
state.selectSession,
|
||||
state.moveSession,
|
||||
]);
|
||||
const chatStore = useChatStore();
|
||||
const onDragEnd: OnDragEndResponder = (result: any) => {
|
||||
const { destination, source } = result;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useDebounce, useDebouncedCallback } from "use-debounce";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import { memo, useState, useRef, useEffect, useLayoutEffect } from "react";
|
||||
|
||||
import SendWhiteIcon from "../icons/send-white.svg";
|
||||
@ -37,7 +37,6 @@ import {
|
||||
isMobileScreen,
|
||||
selectOrCopy,
|
||||
autoGrowTextArea,
|
||||
getCSSVar,
|
||||
} from "../utils";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
@ -414,7 +413,7 @@ export function Chat() {
|
||||
const fontSize = useChatStore((state) => state.config.fontSize);
|
||||
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
const [userInput, setUserInput] = useState("");
|
||||
const [userInput, setUserInput] = useState(session.userInput);
|
||||
const [beforeInput, setBeforeInput] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { submitKey, shouldSubmit } = useSubmitHandler();
|
||||
@ -471,8 +470,23 @@ export function Chat() {
|
||||
},
|
||||
);
|
||||
|
||||
const updateUserInput = (text: string) => {
|
||||
session.userInput = text;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setUserInput(session.userInput);
|
||||
}, [session]);
|
||||
|
||||
// useEffect(() => {
|
||||
// updateUserInput(userInput);
|
||||
// }, [userInput]);
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useEffect(measure, [userInput]);
|
||||
useEffect(() => {
|
||||
measure;
|
||||
updateUserInput(userInput);
|
||||
}, [userInput]);
|
||||
|
||||
// only search prompts when user input is short
|
||||
const SEARCH_TEXT_LIMIT = 30;
|
||||
@ -586,7 +600,7 @@ export function Chat() {
|
||||
: [],
|
||||
)
|
||||
.concat(
|
||||
userInput.length > 0 && config.sendPreviewBubble
|
||||
userInput && userInput.length > 0 && config.sendPreviewBubble
|
||||
? [
|
||||
{
|
||||
...createMessage({
|
||||
|
@ -174,6 +174,7 @@ export interface ChatSession {
|
||||
stat: ChatStat;
|
||||
lastUpdate: string;
|
||||
lastSummarizeIndex: number;
|
||||
userInput: string;
|
||||
}
|
||||
|
||||
const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
||||
@ -199,6 +200,7 @@ function createEmptySession(): ChatSession {
|
||||
},
|
||||
lastUpdate: createDate,
|
||||
lastSummarizeIndex: 0,
|
||||
userInput: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user