import { useCallback, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; import { usePostViewer } from './usePostViewer'; import { useNavigationMemory } from './useNavigationMemory'; import { usePostLabels } from '../settings/usePostLabels'; import PostThreadInline from './PostThreadInline'; import './PostViewerSide.css'; export default function PostViewerSide() { const { activePostUri, mode, close } = usePostViewer(); const navigate = useNavigate(); const { mainContentPath } = useNavigationMemory(); const { t: label } = usePostLabels(); const mainContentPathRef = useRef(mainContentPath); mainContentPathRef.current = mainContentPath; const isOpen = activePostUri !== null && mode === 'side'; const handleClose = useCallback(() => { navigate(mainContentPathRef.current, { replace: true }); close(); }, [navigate, close]); if (!isOpen) return null; return (