From 1db210097c431fa460aea5b8a1bb697fb0f2db6d Mon Sep 17 00:00:00 2001 From: RugerMc <550279039@qq.com> Date: Fri, 31 Mar 2023 13:16:12 +0800 Subject: [PATCH] feat: add switch of send preview bubble --- app/components/home.tsx | 27 ++++++++++++++------------- app/components/settings.tsx | 12 ++++++++++++ app/locales/cn.ts | 1 + app/locales/en.ts | 1 + app/locales/tw.ts | 1 + app/store/app.ts | 2 ++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 2f09aa27..2da10196 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -292,6 +292,8 @@ export function Chat(props: { const latestMessageRef = useRef(null); const [autoScroll, setAutoScroll] = useState(true); + const config = useChatStore((state) => state.config); + // preview messages const messages = (session.messages as RenderMessage[]) .concat( @@ -305,19 +307,18 @@ export function Chat(props: { }, ] : [], - ) - .concat( - userInput.length > 0 - ? [ - { - role: "user", - content: userInput, - date: new Date().toLocaleString(), - preview: true, - }, - ] - : [], - ); + ).concat( + userInput.length > 0 && config.sendPreviewBubble + ? [ + { + role: "user", + content: userInput, + date: new Date().toLocaleString(), + preview: false, + }, + ] + : [], + ); // auto scroll useLayoutEffect(() => { diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 711cb954..06ff76e1 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -278,6 +278,18 @@ export function Settings(props: { closeSettings: () => void }) { } > + + + + updateConfig( + (config) => (config.sendPreviewBubble = e.currentTarget.checked), + ) + } + > +