Skip to content

Commit

Permalink
refactor: remove split state
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Jan 8, 2025
1 parent bd79b35 commit 6b0174a
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/component/main/SplitPaneWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect, useState } from 'react';
import type { SplitPaneSize } from 'react-science/ui';
import { SplitPane } from 'react-science/ui';

Expand All @@ -24,28 +23,21 @@ export function SplitPaneWrapper({ children }) {
},
});
}
const [closed, setClosedValue] = useState(
general?.hidePanelOnLoad ? true : verticalSplitterCloseThreshold,
);

const displayedPanels = items.filter((item) => {
const panelOptions = getPanelPreferences(item);
return panelOptions.display;
});

const hasDisplayedPanels = displayedPanels.length > 0;

useEffect(() => {
if (!hasDisplayedPanels) {
setClosedValue(true);
} else {
setClosedValue(false);
}
}, [hasDisplayedPanels]);

if (items?.length === 0 || !hasDisplayedPanels) {
return <div style={{ width: '100%', height: '100%' }}>{children}</div>;
}

const closed: number | boolean = general?.hidePanelOnLoad
? true
: verticalSplitterCloseThreshold;

return (
<SplitPane
size={verticalSplitterPosition}
Expand Down

0 comments on commit 6b0174a

Please sign in to comment.