1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 06:34:40 +00:00

[dir view] store the open/closed state of the tree panel into localStorage (#6095)

This commit is contained in:
llj
2024-05-17 15:10:09 +08:00
committed by GitHub
parent 0e38b74bd6
commit 96b01defce

View File

@@ -33,9 +33,15 @@ class LibContentView extends React.Component {
constructor(props) {
super(props);
let isTreePanelShown = true;
const storedTreePanelState = localStorage.getItem('sf_dir_view_tree_panel_open');
if (storedTreePanelState != undefined) {
isTreePanelShown = storedTreePanelState == 'true';
}
this.state = {
currentMode: cookie.load('seafile_view_mode') || 'list',
isTreePanelShown: true, // display the 'dirent tree' side panel
isTreePanelShown: isTreePanelShown, // display the 'dirent tree' side panel
path: '',
pathExist: true,
isViewFile: false,
@@ -1948,6 +1954,11 @@ class LibContentView extends React.Component {
toggleTreePanel = () => {
this.setState({
isTreePanelShown: !this.state.isTreePanelShown
}, () => {
if (this.state.isTreePanelShown) {
this.loadSidePanel(this.state.path);
}
localStorage.setItem('sf_dir_view_tree_panel_open', String(this.state.isTreePanelShown));
});
};