import SmartViewsSection from '@/Components/Tags/SmartViewsSection' import TagsSection from '@/Components/Tags/TagsSection' import { WebApplication } from '@/Application/Application' import { PANEL_NAME_NAVIGATION } from '@/Constants/Constants' import { ApplicationEvent, PrefKey } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import { FunctionComponent, useCallback, useEffect, useMemo, useState } from 'react' import PanelResizer, { PanelSide, ResizeFinishCallback, PanelResizeType } from '@/Components/PanelResizer/PanelResizer' type Props = { application: WebApplication } const Navigation: FunctionComponent = ({ application }) => { const viewControllerManager = useMemo(() => application.getViewControllerManager(), [application]) const [ref, setRef] = useState() const [panelWidth, setPanelWidth] = useState(0) useEffect(() => { const removeObserver = application.addEventObserver(async () => { const width = application.getPreference(PrefKey.TagsPanelWidth) if (width) { setPanelWidth(width) } }, ApplicationEvent.PreferencesChanged) return () => { removeObserver() } }, [application]) const panelResizeFinishCallback: ResizeFinishCallback = useCallback( (width, _lastLeft, _isMaxWidth, isCollapsed) => { application.setPreference(PrefKey.TagsPanelWidth, width).catch(console.error) viewControllerManager.noteTagsController.reloadTagsContainerMaxWidth() application.publishPanelDidResizeEvent(PANEL_NAME_NAVIGATION, isCollapsed) }, [application, viewControllerManager], ) const panelWidthEventCallback = useCallback(() => { viewControllerManager.noteTagsController.reloadTagsContainerMaxWidth() }, [viewControllerManager]) return ( ) } export default observer(Navigation)