2023-02-13 01:55:52 +01:00
|
|
|
import React, { ComponentType, FC } from 'react';
|
|
|
|
import dynamic from 'next/dynamic';
|
|
|
|
import { Skeleton, TabsProps } from 'antd';
|
|
|
|
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 { ActionButtonMenu } from '../../action-buttons/ActionButtonMenu/ActionButtonMenu';
|
|
|
|
import { ExternalAction } from '../../../interfaces/external-action';
|
|
|
|
|
|
|
|
export type MobileContentProps = {
|
|
|
|
name: string;
|
|
|
|
summary: string;
|
|
|
|
tags: string[];
|
|
|
|
socialHandles: SocialLink[];
|
|
|
|
extraPageContent: string;
|
|
|
|
notifyItemSelected: () => void;
|
|
|
|
followItemSelected: () => void;
|
|
|
|
setExternalActionToDisplay: (action: ExternalAction) => void;
|
|
|
|
setShowNotifyPopup: (show: boolean) => void;
|
|
|
|
setShowFollowModal: (show: boolean) => void;
|
|
|
|
supportFediverseFeatures: boolean;
|
|
|
|
messages: ChatMessage[];
|
|
|
|
currentUser: CurrentUser;
|
|
|
|
showChat: boolean;
|
2023-03-02 01:19:02 +01:00
|
|
|
chatEnabled: boolean;
|
2023-02-13 01:55:52 +01:00
|
|
|
actions: ExternalAction[];
|
|
|
|
externalActionSelected: (action: ExternalAction) => void;
|
|
|
|
supportsBrowserNotifications: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
// lazy loaded components
|
|
|
|
|
|
|
|
const Tabs: ComponentType<TabsProps> = 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,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-03-06 02:47:59 +01:00
|
|
|
type ChatContentProps = {
|
|
|
|
showChat: boolean;
|
|
|
|
chatEnabled: boolean;
|
|
|
|
messages: ChatMessage[];
|
|
|
|
currentUser: CurrentUser;
|
|
|
|
};
|
|
|
|
|
|
|
|
const ChatContent: FC<ChatContentProps> = ({ showChat, chatEnabled, messages, currentUser }) => {
|
|
|
|
const { id, displayName } = currentUser;
|
|
|
|
|
|
|
|
return showChat && !!currentUser ? (
|
|
|
|
<ChatContainer
|
|
|
|
messages={messages}
|
|
|
|
usernameToHighlight={displayName}
|
|
|
|
chatUserId={id}
|
|
|
|
isModerator={false}
|
|
|
|
chatAvailable={chatEnabled}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Skeleton loading active paragraph={{ rows: 7 }} />
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-02-13 01:55:52 +01:00
|
|
|
export const MobileContent: FC<MobileContentProps> = ({
|
|
|
|
name,
|
|
|
|
summary,
|
|
|
|
tags,
|
|
|
|
socialHandles,
|
|
|
|
extraPageContent,
|
|
|
|
messages,
|
|
|
|
currentUser,
|
|
|
|
showChat,
|
2023-03-02 01:19:02 +01:00
|
|
|
chatEnabled,
|
2023-02-13 01:55:52 +01:00
|
|
|
actions,
|
|
|
|
setExternalActionToDisplay,
|
|
|
|
setShowNotifyPopup,
|
|
|
|
setShowFollowModal,
|
|
|
|
supportFediverseFeatures,
|
|
|
|
supportsBrowserNotifications,
|
|
|
|
}) => {
|
|
|
|
const aboutTabContent = (
|
|
|
|
<>
|
2023-02-23 03:39:37 +01:00
|
|
|
<ContentHeader name={name} summary={summary} tags={tags} links={socialHandles} logo="/logo" />
|
2023-02-28 02:39:45 +01:00
|
|
|
{!!extraPageContent && (
|
|
|
|
<div className={styles.bottomPageContentContainer}>
|
|
|
|
<CustomPageContent content={extraPageContent} />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-02-13 01:55:52 +01:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
const followersTabContent = (
|
2023-02-22 01:15:09 +01:00
|
|
|
<div className={styles.bottomPageContentContainer}>
|
|
|
|
<FollowerCollection name={name} onFollowButtonClick={() => setShowFollowModal(true)} />
|
|
|
|
</div>
|
2023-02-13 01:55:52 +01:00
|
|
|
);
|
|
|
|
|
2023-02-22 01:15:09 +01:00
|
|
|
const items = [];
|
|
|
|
if (showChat) {
|
2023-03-06 02:47:59 +01:00
|
|
|
items.push({
|
|
|
|
label: 'Chat',
|
|
|
|
key: '0',
|
|
|
|
children: (
|
|
|
|
<ChatContent
|
|
|
|
showChat={showChat}
|
|
|
|
chatEnabled={chatEnabled}
|
|
|
|
messages={messages}
|
|
|
|
currentUser={currentUser}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
});
|
2023-02-22 01:15:09 +01:00
|
|
|
}
|
|
|
|
items.push({ label: 'About', key: '2', children: aboutTabContent });
|
|
|
|
if (supportFediverseFeatures) {
|
|
|
|
items.push({ label: 'Followers', key: '3', children: followersTabContent });
|
|
|
|
}
|
2023-02-13 01:55:52 +01:00
|
|
|
|
|
|
|
const replacementTabBar = (props, DefaultTabBar) => (
|
|
|
|
<div className={styles.replacementBar}>
|
|
|
|
<DefaultTabBar {...props} className={styles.defaultTabBar} />
|
|
|
|
<ActionButtonMenu
|
|
|
|
className={styles.actionButtonMenu}
|
|
|
|
showFollowItem={supportFediverseFeatures}
|
|
|
|
showNotifyItem={supportsBrowserNotifications}
|
|
|
|
actions={actions}
|
|
|
|
externalActionSelected={setExternalActionToDisplay}
|
|
|
|
notifyItemSelected={() => setShowNotifyPopup(true)}
|
|
|
|
followItemSelected={() => setShowFollowModal(true)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.lowerSectionMobile}>
|
2023-02-22 01:15:09 +01:00
|
|
|
{items.length > 1 ? (
|
|
|
|
<Tabs
|
|
|
|
className={styles.tabs}
|
|
|
|
defaultActiveKey="0"
|
|
|
|
items={items}
|
|
|
|
renderTabBar={replacementTabBar}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
aboutTabContent
|
|
|
|
)}
|
2023-02-13 01:55:52 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|