import React, { ComponentType, FC } from 'react'; import dynamic from 'next/dynamic'; import { Skeleton, TabsProps } from 'antd'; import { ErrorBoundary } from 'react-error-boundary'; import classNames from 'classnames'; import { SocialLink } from '../../../interfaces/social-link.model'; import styles from './Content.module.scss'; import { CustomPageContent } from '../CustomPageContent/CustomPageContent'; import { ContentHeader } from '../../common/ContentHeader/ContentHeader'; import { ChatMessage } from '../../../interfaces/chat-message.model'; import { CurrentUser } from '../../../interfaces/current-user'; import { ComponentError } from '../ComponentError/ComponentError'; export type MobileContentProps = { name: string; summary: string; tags: string[]; socialHandles: SocialLink[]; extraPageContent: string; setShowFollowModal: (show: boolean) => void; supportFediverseFeatures: boolean; messages: ChatMessage[]; currentUser: CurrentUser; showChat: boolean; chatEnabled: boolean; online: boolean; }; // lazy loaded components const Tabs: ComponentType = dynamic(() => import('antd').then(mod => mod.Tabs), { ssr: false, }); const FollowerCollection = dynamic( () => import('../followers/FollowerCollection/FollowerCollection').then( mod => mod.FollowerCollection, ), { ssr: false, }, ); const ChatContainer = dynamic( () => import('../../chat/ChatContainer/ChatContainer').then(mod => mod.ChatContainer), { ssr: false, }, ); type ChatContentProps = { showChat: boolean; chatEnabled: boolean; messages: ChatMessage[]; currentUser: CurrentUser; }; const ComponentErrorFallback = ({ error, resetErrorBoundary }) => ( ); const ChatContent: FC = ({ showChat, chatEnabled, messages, currentUser }) => { const { id, displayName } = currentUser; return showChat && !!currentUser ? ( ) : ( ); }; export const MobileContent: FC = ({ name, summary, tags, socialHandles, extraPageContent, messages, currentUser, showChat, chatEnabled, setShowFollowModal, supportFediverseFeatures, online, }) => { const aboutTabContent = ( <> {!!extraPageContent && (
)} ); const followersTabContent = (
setShowFollowModal(true)} />
); const items = []; if (showChat && currentUser) { items.push({ label: 'Chat', key: '0', children: ( ), }); } items.push({ label: 'About', key: '2', children: aboutTabContent }); if (supportFediverseFeatures) { items.push({ label: 'Followers', key: '3', children: followersTabContent }); } return ( ( )} > {items.length > 1 ? (
) : (
{aboutTabContent}
)}
); };