import { useEffect, useCallback } from 'react'; import { useIntl, defineMessages } from 'react-intl'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; import type { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import elephantUIPlane from '@/images/elephant_ui_plane.svg'; import EditIcon from '@/material-icons/400-24px/edit_square.svg?react'; import PeopleIcon from '@/material-icons/400-24px/group.svg?react'; import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react'; import LogoutIcon from '@/material-icons/400-24px/logout.svg?react'; import MenuIcon from '@/material-icons/400-24px/menu.svg?react'; import NotificationsIcon from '@/material-icons/400-24px/notifications-fill.svg?react'; import PublicIcon from '@/material-icons/400-24px/public.svg?react'; import SettingsIcon from '@/material-icons/400-24px/settings.svg?react'; import { mountCompose, unmountCompose } from 'mastodon/actions/compose'; import { openModal } from 'mastodon/actions/modal'; import { Column } from 'mastodon/components/column'; import { ColumnHeader } from 'mastodon/components/column_header'; import { Icon } from 'mastodon/components/icon'; import { mascot, reduceMotion } from 'mastodon/initial_state'; import { useAppDispatch, useAppSelector } from 'mastodon/store'; import { messages as navbarMessages } from '../ui/components/navigation_bar'; import { Search } from './components/search'; import ComposeFormContainer from './containers/compose_form_container'; const messages = defineMessages({ live_feed_public: { id: 'navigation_bar.live_feed_public', defaultMessage: 'Live feed (public)', }, live_feed_local: { id: 'navigation_bar.live_feed_local', defaultMessage: 'Live feed (local)', }, preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences', }, logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' }, }); type ColumnMap = ImmutableMap<'id' | 'uuid' | 'params', string>; const Compose: React.FC<{ multiColumn: boolean }> = ({ multiColumn }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const columns = useAppSelector( (state) => (state.settings as ImmutableMap).get( 'columns', ) as ImmutableList, ); useEffect(() => { dispatch(mountCompose()); return () => { dispatch(unmountCompose()); }; }, [dispatch]); const handleLogoutClick = useCallback( (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); dispatch(openModal({ modalType: 'CONFIRM_LOG_OUT', modalProps: {} })); return false; }, [dispatch], ); const scrollNavbarIntoView = useCallback(() => { const navbar = document.querySelector('.navigation-panel'); navbar?.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', }); }, []); if (multiColumn) { return (
); } return (
); }; // eslint-disable-next-line import/no-default-export export default Compose;