优化代码风格

保持已有的状态库的使用风格,通过箭头函数来指定 handler 函数参数
This commit is contained in:
Jinmiao Luo
2023-04-29 14:33:08 +08:00
parent 0910332f9a
commit 739f5a5a08

View File

@@ -81,13 +81,8 @@ function useDragSideBar() {
}
export function SideBar(props: { className?: string }) {
const [newSession, deleteSession, currentSessionIndex] = useChatStore(
(state) => [
state.newSession,
state.deleteSession,
state.currentSessionIndex,
],
);
const chatStore = useChatStore();
// drag side bar
const { onDragMouseDown, shouldNarrow } = useDragSideBar();
const navigate = useNavigate();
@@ -144,7 +139,7 @@ export function SideBar(props: { className?: string }) {
<IconButton
icon={<CloseIcon />}
onClick={() => {
deleteSession(currentSessionIndex);
chatStore.deleteSession(chatStore.currentSessionIndex);
}}
/>
</div>
@@ -165,7 +160,7 @@ export function SideBar(props: { className?: string }) {
text={shouldNarrow ? undefined : Locale.Home.NewChat}
onClick={() => {
if (config.dontShowMaskSplashScreen) {
newSession();
chatStore.newSession();
} else {
navigate(Path.NewChat);
}