import { SmartViewsSection } from '@/Components/Tags/SmartViewsSection' import { TagsSection } from '@/Components/Tags/TagsSection' import { WebApplication } from '@/UIModels/Application' import { PANEL_NAME_NAVIGATION } from '@/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 '@/Components/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).catch(console.error) appState.noteTags.reloadTagsContainerMaxWidth() appState.panelDidResize(PANEL_NAME_NAVIGATION, isCollapsed) }, [application, appState], ) const panelWidthEventCallback = useCallback(() => { appState.noteTags.reloadTagsContainerMaxWidth() }, [appState]) return ( ) })