import { useRef } from 'react'; import styles from './home.module.css'; import { Link, useNavigate } from 'react-router-dom'; import { Trans, useTranslation } from 'react-i18next'; import { Subplebbit, useSubplebbits } from '@plebbit/plebbit-react-hooks'; import packageJson from '../../../package.json'; import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits'; const isValidAddress = (address: string): boolean => { if (address.includes('/') || address.includes('\\') || address.includes(' ')) { return false; } return true; }; const SearchBar = () => { const searchInputRef = useRef(null); const { t } = useTranslation(); const navigate = useNavigate(); const handleSearchSubmit = () => { const inputValue = searchInputRef.current?.value; if (inputValue && isValidAddress(inputValue)) { navigate(`/p/${inputValue}`); } else { alert('invalid address'); } }; return (
{ if (e.key === 'Enter') { handleSearchSubmit(); } }} />
); }; const InfoBox = () => { const { t } = useTranslation(); return (

{t('what_is_plebchan')}

}} />

{t('no_global_rules_info')}
); }; const Boards = ({ subplebbits }: { subplebbits: (Subplebbit | undefined)[] }) => { const { t } = useTranslation(); return (

{t('boards')}

{t('options')} ▼

Default SFW

{subplebbits .filter((subplebbit: Subplebbit | undefined): subplebbit is Subplebbit => subplebbit !== undefined) .map((subplebbit: Subplebbit) => { const address = subplebbit.address; return (
{address}
); })}

Default NSFW

Subscriptions

Moderating

); }; const PopularThreads = () => { const { t } = useTranslation(); return (

{t('popular_threads')}

{t('options')} ▼
); }; const Stats = () => { const { t } = useTranslation(); return (

{t('stats')}

); }; const { version } = packageJson; const downloadAppLink = (() => { const platform = navigator.platform; if (platform === 'Linux' || platform === 'Linux x86_64' || platform === 'Linux i686' || platform === 'Linux aarch64') { return `https://github.com/plebbit/plebchan/releases/download/v${version}/plebchan-${version}.AppImage`; } else if (platform === 'Win32' || platform === 'Win64' || platform === 'Windows') { return `https://github.com/plebbit/plebchan/releases/download/v${version}/plebchan.Portable.${version}.exe`; } else if (platform === 'MacIntel' || platform === 'Macintosh') { return `https://github.com/plebbit/plebchan/releases/download/v${version}/plebchan-${version}.dmg`; } else if (platform === 'Android') { return undefined; } else if (platform === 'iPhone' || platform === 'iPad') { return undefined; } else { return undefined; } })(); const isElectron = window.isElectron === true; const commitRef = process.env.REACT_APP_COMMIT_REF; const Footer = () => { const { t } = useTranslation(); return ( <>
v{packageJson.version} {isElectron && ( node stats )} {commitRef && ( #{commitRef.slice(0, 7)} )}
); }; const Home = () => { const subplebbitAddresses = useDefaultSubplebbitAddresses(); const { subplebbits } = useSubplebbits({ subplebbitAddresses }); return (
); }; export default Home;