/* eslint-disable react/no-danger */ import { useRecoilValue } from 'recoil'; import { Layout, Tabs, Spin } from 'antd'; import { useEffect, useState } from 'react'; import { LOCAL_STORAGE_KEYS, getLocalStorage, setLocalStorage } from '../../../utils/localStorage'; import { clientConfigStateAtom, chatMessagesAtom, chatDisplayNameAtom, chatUserIdAtom, isChatVisibleSelector, serverStatusState, appStateAtom, isOnlineSelector, } from '../../stores/ClientConfigStore'; import { ClientConfig } from '../../../interfaces/client-config.model'; import CustomPageContent from '../../CustomPageContent'; import OwncastPlayer from '../../video/OwncastPlayer'; import FollowerCollection from '../../FollowersCollection'; import s from './Content.module.scss'; import Sidebar from '../Sidebar'; import Footer from '../Footer'; import ChatContainer from '../../chat/ChatContainer'; import { ChatMessage } from '../../../interfaces/chat-message.model'; import ChatTextField from '../../chat/ChatTextField/ChatTextField'; import ActionButtonRow from '../../action-buttons/ActionButtonRow'; import ActionButton from '../../action-buttons/ActionButton'; import Statusbar from '../Statusbar/Statusbar'; import { ServerStatus } from '../../../interfaces/server-status.model'; import { Follower } from '../../../interfaces/follower'; import SocialLinks from '../SocialLinks/SocialLinks'; import NotifyReminderPopup from '../NotifyReminderPopup/NotifyReminderPopup'; import ServerLogo from '../Logo/Logo'; import CategoryIcon from '../CategoryIcon/CategoryIcon'; import OfflineBanner from '../OfflineBanner/OfflineBanner'; import { AppStateOptions } from '../../stores/application-state'; import FollowButton from '../../action-buttons/FollowButton'; import NotifyButton from '../../action-buttons/NotifyButton'; import Modal from '../Modal/Modal'; import BrowserNotifyModal from '../../modals/BrowserNotify/BrowserNotifyModal'; const { TabPane } = Tabs; const { Content } = Layout; export default function ContentComponent() { const appState = useRecoilValue(appStateAtom); const status = useRecoilValue(serverStatusState); const clientConfig = useRecoilValue(clientConfigStateAtom); const isChatVisible = useRecoilValue(isChatVisibleSelector); const messages = useRecoilValue(chatMessagesAtom); const online = useRecoilValue(isOnlineSelector); const chatDisplayName = useRecoilValue(chatDisplayNameAtom); const chatUserId = useRecoilValue(chatUserIdAtom); const { extraPageContent, version, socialHandles, name, title, tags, summary } = clientConfig; const { viewerCount, lastConnectTime, lastDisconnectTime } = status; const [showNotifyReminder, setShowNotifyReminder] = useState(false); const [showNotifyPopup, setShowNotifyPopup] = useState(false); const followers: Follower[] = []; const total = 0; // This is example content. It should be removed. const externalActions = [ { url: 'https://owncast.online/docs', title: 'Example button', description: 'Example button description', icon: 'https://owncast.online/images/logo.svg', color: '#5232c8', openExternally: false, }, ]; const externalActionButtons = externalActions.map(action => ( )); const incrementVisitCounter = () => { let visits = parseInt(getLocalStorage(LOCAL_STORAGE_KEYS.userVisitCount), 10); if (Number.isNaN(visits)) { visits = 0; } setLocalStorage(LOCAL_STORAGE_KEYS.userVisitCount, visits + 1); if (visits > 2 && !getLocalStorage(LOCAL_STORAGE_KEYS.hasDisplayedNotificationModal)) { setShowNotifyReminder(true); } }; const disableNotifyReminderPopup = () => { setShowNotifyPopup(false); setShowNotifyReminder(false); setLocalStorage(LOCAL_STORAGE_KEYS.hasDisplayedNotificationModal, true); }; useEffect(() => { incrementVisitCounter(); }, []); return (
{online && } {!online && ( )}
{externalActionButtons} setShowNotifyPopup(true)} notificationClosed={() => disableNotifyReminderPopup()} > setShowNotifyPopup(true)} /> disableNotifyReminderPopup()} handleCancel={() => disableNotifyReminderPopup()} >
{name}
{title}
{tags.length > 0 && tags.map(tag => #{tag} )}
{isChatVisible && (
)}
{isChatVisible && } ); }