From c37885e743f02f7102816f0c96f86c124f3d8b1e Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Mon, 1 May 2023 23:21:28 +0800 Subject: [PATCH] fix: #1130 #1131 delete right session --- app/components/chat-list.tsx | 13 ++++-- app/components/sidebar.tsx | 6 ++- app/components/ui-lib.tsx | 8 +++- app/store/chat.ts | 89 ++++++++++++++++-------------------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/app/components/chat-list.tsx b/app/components/chat-list.tsx index 2c7b95aa..02ea086b 100644 --- a/app/components/chat-list.tsx +++ b/app/components/chat-list.tsx @@ -67,7 +67,10 @@ export function ChatItem(props: { )} -
+
@@ -77,14 +80,14 @@ export function ChatItem(props: { } export function ChatList(props: { narrow?: boolean }) { - const [sessions, selectedIndex, selectSession, removeSession, moveSession] = - useChatStore((state) => [ + const [sessions, selectedIndex, selectSession, moveSession] = useChatStore( + (state) => [ state.sessions, state.currentSessionIndex, state.selectSession, - state.removeSession, state.moveSession, - ]); + ], + ); const chatStore = useChatStore(); const navigate = useNavigate(); diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 47a31172..77621964 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -138,7 +138,11 @@ export function SideBar(props: { className?: string }) {
} - onClick={chatStore.deleteSession} + onClick={() => { + if (confirm(Locale.Home.DeleteChat)) { + chatStore.deleteSession(chatStore.currentSessionIndex); + } + }} />
diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index 5b6ed959..c16f94a4 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -158,6 +158,7 @@ export type ToastProps = { text: string; onClick: () => void; }; + onClose?: () => void; }; export function Toast(props: ToastProps) { @@ -167,7 +168,10 @@ export function Toast(props: ToastProps) { {props.content} {props.action && (