1414
1515import React from "react" ;
1616import { Button , Drawer , Modal , Spin } from "antd" ;
17- import { BarsOutlined , CloseCircleFilled } from "@ant-design/icons" ;
17+ import { BarsOutlined , CloseCircleFilled , MenuFoldOutlined , MenuUnfoldOutlined } from "@ant-design/icons" ;
1818import moment from "moment" ;
1919import * as StoreBackend from "./backend/StoreBackend" ;
2020import ChatMenu from "./ChatMenu" ;
@@ -39,6 +39,9 @@ class ChatPage extends BaseListPage {
3939 }
4040
4141 UNSAFE_componentWillMount ( ) {
42+ const savedCollapsedState = localStorage . getItem ( "chatMenuCollapsed" ) ;
43+ const chatMenuCollapsed = savedCollapsedState ? JSON . parse ( savedCollapsedState ) : false ;
44+
4245 this . setState ( {
4346 loading : true ,
4447 disableInput : false ,
@@ -47,6 +50,7 @@ class ChatPage extends BaseListPage {
4750 messageError : false ,
4851 autoRead : false ,
4952 chatMenuVisible : false ,
53+ chatMenuCollapsed : chatMenuCollapsed ,
5054 defaultStore : null ,
5155 filteredStores : [ ] ,
5256 paneCount : 1 ,
@@ -85,6 +89,14 @@ class ChatPage extends BaseListPage {
8589 } ) ;
8690 } ;
8791
92+ toggleChatMenuCollapse = ( ) => {
93+ const newCollapsedState = ! this . state . chatMenuCollapsed ;
94+ this . setState ( {
95+ chatMenuCollapsed : newCollapsedState ,
96+ } ) ;
97+ localStorage . setItem ( "chatMenuCollapsed" , JSON . stringify ( newCollapsedState ) ) ;
98+ } ;
99+
88100 getGlobalStores ( ) {
89101 StoreBackend . getGlobalStores ( "" , "" , "" , "" , "" , "" ) . then ( ( res ) => {
90102 if ( res . status === "ok" ) {
@@ -642,7 +654,7 @@ class ChatPage extends BaseListPage {
642654 this . renderUnsafePasswordModal ( )
643655 }
644656 {
645- ! ( Setting . isMobile ( ) || Setting . getUrlParam ( "isRaw" ) !== null ) && (
657+ ! ( Setting . isMobile ( ) || Setting . getUrlParam ( "isRaw" ) !== null ) && ! this . state . chatMenuCollapsed && (
646658 < div style = { { width : "250px" , height : "100%" , backgroundColor : "white" , marginRight : "2px" } } >
647659 < ChatMenu ref = { this . menu } chats = { chats } chatName = { this . getChat ( ) } onSelectChat = { onSelectChat } onAddChat = { onAddChat } onDeleteChat = { onDeleteChat } onUpdateChatName = { onUpdateChatName } stores = { this . state . stores } />
648660 </ div >
@@ -658,10 +670,13 @@ class ChatPage extends BaseListPage {
658670
659671 < div style = { { flex : 1 , height : "100%" , backgroundColor : "white" , position : "relative" , display : "flex" , flexDirection : "column" } } >
660672 { this . state . chat && this . state . paneCount === 1 && (
661- < div style = { { display : "flex" , alignItems : "center" } } >
673+ < div style = { { display : "flex" , alignItems : "center" , marginLeft : "15px" } } >
662674 { Setting . isMobile ( ) && (
663675 < Button type = "text" icon = { < BarsOutlined /> } onClick = { this . toggleChatMenu } style = { { marginRight : "8px" } } />
664676 ) }
677+ { ! ( Setting . isMobile ( ) || Setting . getUrlParam ( "isRaw" ) !== null ) && (
678+ < Button type = "text" icon = { this . state . chatMenuCollapsed ? < MenuUnfoldOutlined /> : < MenuFoldOutlined /> } onClick = { this . toggleChatMenuCollapse } style = { { marginRight : "8px" } } />
679+ ) }
665680 < div style = { { flex : 1 } } >
666681 < StoreInfoTitle chat = { this . state . chat } stores = { this . state . stores } autoRead = { this . state . autoRead } onUpdateAutoRead = { ( checked ) => this . setState ( { autoRead : checked } ) } account = { this . props . account } paneCount = { this . state . paneCount } onPaneCountChange = { ( count ) => this . setState ( { paneCount : count } ) } showPaneControls = { true } />
667682 </ div >
0 commit comments