2022-07-08 10:10:18 +03:00
|
|
|
import { useRecoilValue } from 'recoil';
|
2022-07-08 23:20:22 +03:00
|
|
|
import cn from 'classnames';
|
|
|
|
import { EyeFilled } from '@ant-design/icons';
|
|
|
|
import { useEffect } from 'react';
|
2022-07-08 10:10:18 +03:00
|
|
|
import { ClientConfig } from '../../../interfaces/client-config.model';
|
2022-07-08 23:20:22 +03:00
|
|
|
import {
|
|
|
|
clientConfigStateAtom,
|
|
|
|
isOnlineSelector,
|
|
|
|
serverStatusState,
|
|
|
|
} from '../../stores/ClientConfigStore';
|
2022-07-08 10:10:18 +03:00
|
|
|
import { ServerLogo } from '../../ui';
|
2022-07-08 23:20:22 +03:00
|
|
|
import StatusBar from '../../ui/Statusbar';
|
2022-07-08 10:10:18 +03:00
|
|
|
import CategoryIcon from '../../ui/CategoryIcon/CategoryIcon';
|
|
|
|
import SocialLinks from '../../ui/SocialLinks/SocialLinks';
|
|
|
|
import s from './StreamInfo.module.scss';
|
2022-07-08 23:20:22 +03:00
|
|
|
import { ServerStatus } from '../../../interfaces/server-status.model';
|
2022-07-08 10:10:18 +03:00
|
|
|
|
2022-07-08 23:20:22 +03:00
|
|
|
interface Props {
|
|
|
|
isMobile: boolean;
|
|
|
|
}
|
|
|
|
export default function StreamInfo({ isMobile }: Props) {
|
2022-07-08 10:10:18 +03:00
|
|
|
const { socialHandles, name, title, tags } = useRecoilValue<ClientConfig>(clientConfigStateAtom);
|
2022-07-08 23:20:22 +03:00
|
|
|
const { viewerCount, lastConnectTime, lastDisconnectTime } =
|
|
|
|
useRecoilValue<ServerStatus>(serverStatusState);
|
|
|
|
const online = useRecoilValue<boolean>(isOnlineSelector);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
console.log({ online });
|
|
|
|
}, [online]);
|
2022-07-08 10:10:18 +03:00
|
|
|
|
2022-07-08 23:20:22 +03:00
|
|
|
return isMobile ? (
|
|
|
|
<div className={cn(s.root, s.mobile)}>
|
|
|
|
<div className={s.mobileInfo}>
|
|
|
|
<ServerLogo src="/logo" />
|
|
|
|
<div className={s.title}>{name}</div>
|
|
|
|
</div>
|
|
|
|
<div className={s.mobileStatus}>
|
|
|
|
<div className={s.viewerCount}>
|
|
|
|
{online && (
|
|
|
|
<>
|
|
|
|
<span>{viewerCount}</span>
|
|
|
|
<EyeFilled />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className={s.liveStatus}>
|
|
|
|
{online && <div className={s.liveCircle} />}
|
|
|
|
<span>{online ? 'LIVE' : 'OFFLINE'}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className={s.root}>
|
2022-07-08 10:10:18 +03:00
|
|
|
<div className={s.logoTitleSection}>
|
|
|
|
<ServerLogo src="/logo" />
|
|
|
|
<div className={s.titleSection}>
|
|
|
|
<div className={s.title}>{name}</div>
|
|
|
|
<div className={s.subtitle}>
|
|
|
|
{title}
|
|
|
|
<CategoryIcon tags={tags} />
|
|
|
|
</div>
|
|
|
|
<div>{tags.length > 0 && tags.map(tag => <span key={tag}>#{tag} </span>)}</div>
|
|
|
|
<SocialLinks links={socialHandles} />
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-08 23:20:22 +03:00
|
|
|
<StatusBar
|
|
|
|
online={online}
|
|
|
|
lastConnectTime={lastConnectTime}
|
|
|
|
lastDisconnectTime={lastDisconnectTime}
|
|
|
|
viewerCount={viewerCount}
|
|
|
|
/>
|
2022-07-08 10:10:18 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|