import { SmartTagsSection } from '@/components/Tags/SmartTagsSection'; import { TagsSection } from '@/components/Tags/TagsSection'; import { WebApplication } from '@/ui_models/application'; import { PANEL_NAME_NAVIGATION } from '@/views/constants'; import { ApplicationEvent, PrefKey } from '@standardnotes/snjs'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'; import { PanelSide, ResizeFinishCallback, PanelResizer, PanelResizeType, } from './PanelResizer'; type Props = { application: WebApplication; }; export const Navigation: FunctionComponent = observer( ({ application }) => { const appState = useMemo(() => application.getAppState(), [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); appState.noteTags.reloadTagsContainerMaxWidth(); appState.panelDidResize(PANEL_NAME_NAVIGATION, isCollapsed); }, [application, appState] ); const panelWidthEventCallback = useCallback(() => { appState.noteTags.reloadTagsContainerMaxWidth(); }, [appState]); return ( ); } );