优化代码风格

保持已有的状态库的使用风格,通过箭头函数来指定 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 }) { export function SideBar(props: { className?: string }) {
const [newSession, deleteSession, currentSessionIndex] = useChatStore( const chatStore = useChatStore();
(state) => [
state.newSession,
state.deleteSession,
state.currentSessionIndex,
],
);
// drag side bar // drag side bar
const { onDragMouseDown, shouldNarrow } = useDragSideBar(); const { onDragMouseDown, shouldNarrow } = useDragSideBar();
const navigate = useNavigate(); const navigate = useNavigate();
@@ -144,7 +139,7 @@ export function SideBar(props: { className?: string }) {
<IconButton <IconButton
icon={<CloseIcon />} icon={<CloseIcon />}
onClick={() => { onClick={() => {
deleteSession(currentSessionIndex); chatStore.deleteSession(chatStore.currentSessionIndex);
}} }}
/> />
</div> </div>
@@ -165,7 +160,7 @@ export function SideBar(props: { className?: string }) {
text={shouldNarrow ? undefined : Locale.Home.NewChat} text={shouldNarrow ? undefined : Locale.Home.NewChat}
onClick={() => { onClick={() => {
if (config.dontShowMaskSplashScreen) { if (config.dontShowMaskSplashScreen) {
newSession(); chatStore.newSession();
} else { } else {
navigate(Path.NewChat); navigate(Path.NewChat);
} }