import styles from 'styles/Main.module.scss' import { useMemo } from 'react' import Image from 'next/image' import useUser from 'hooks/useUser' import useSettings from 'hooks/useSettings' import useApps from 'hooks/useApps' import useMediaQuery from 'hooks/useMediaQuery' import { Layout, App, Splash } from 'components' import { open } from 'helpers/windowActions' import appList from 'configs/appList' const Home = () => { const { t } = useSettings() const { apps, setApps } = useApps() const touchDevice = useMediaQuery('(pointer: coarse)') const { user } = useUser({ redirectToLogin: true, redirectToVerify: true, redirectToApps: true }) if (!user) { return (
) } const handleClick = (e, appProps) => { switch (e.detail) { case 1: touchDevice ? open(appProps, setApps) : e.currentTarget.focus() break case 2: open(appProps, setApps) e.currentTarget.blur() break } } const handleKey = (e, appProps) => { if (e.key === 'Enter') { open(appProps, setApps) } } return ( <> { Object.entries(appList).filter(a => a[1].icon).map(a => (
handleClick(e, { appName: a[0], ...a[1] })} onKeyDown={e => handleKey(e, { appName: a[0], ...a[1] })} tabIndex='0' > {`${a[0]}

{t(a[0])}

)) } {apps && apps.length > 0 && apps.map(app => { if (!app) return null const AppComponent = appList[app.name].component return ( ) })}
) } const AppContainer = ({ AppComponent, appProps }) => { const Component = useMemo(() => , [appProps]) return Component } export default Home