Skip to content

Commit

Permalink
fix: Optimize the initialization method for masterPaneController (#2333)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyJinSS authored Aug 1, 2023
1 parent 2bbb409 commit 14390f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/plugin-outline-pane/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export function OutlinePaneContext(props: {
hideFilter?: boolean;
}) {
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
const [masterPaneController, setMasterPaneController] = useState(
() => new PaneController(props.paneName || MasterPaneName, treeMaster),
);
useEffect(() => {
return treeMaster.onPluginContextChange(() => {
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
Expand All @@ -40,7 +42,9 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
const { skeleton, config, canvas, project } = ctx;

let isInFloatArea = true;
const hasPreferenceForOutline = config.getPreference().contains('outline-pane-pinned-status-isFloat', 'skeleton');
const hasPreferenceForOutline = config
.getPreference()
.contains('outline-pane-pinned-status-isFloat', 'skeleton');
if (hasPreferenceForOutline) {
isInFloatArea = config.getPreference().get('outline-pane-pinned-status-isFloat', 'skeleton');
}
Expand Down Expand Up @@ -160,4 +164,4 @@ OutlinePlugin.meta = {
],
},
};
OutlinePlugin.pluginName = 'OutlinePlugin';
OutlinePlugin.pluginName = 'OutlinePlugin';

0 comments on commit 14390f0

Please sign in to comment.