X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fapp%2Findex.js;h=2c80c798bccb397862cb29e576345ef59da594ff;hb=9ac5e263a259207e3ecd132188df41f7c3315b88;hp=fcc5311ec6404deaba12e4ed1c16c7f58b75b6f9;hpb=16662be0b3432d67307ae8c2bb798362d77bab99;p=alttp.git diff --git a/resources/js/app/index.js b/resources/js/app/index.js index fcc5311..2c80c79 100644 --- a/resources/js/app/index.js +++ b/resources/js/app/index.js @@ -1,47 +1,16 @@ -import axios from 'axios'; -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { Helmet } from 'react-helmet'; import { useTranslation } from 'react-i18next'; -import { BrowserRouter } from 'react-router-dom'; import Routes from './Routes'; import AlttpBaseRomProvider from '../helpers/AlttpBaseRomContext'; -import UserContext from '../helpers/UserContext'; +import { UserProvider } from '../hooks/user'; import i18n from '../i18n'; const App = () => { - const [user, setUser] = useState(null); - const { t } = useTranslation(); - const checkAuth = async () => { - try { - const response = await axios.get('/api/user'); - setUser(response.data); - } catch (e) { - setUser(null); - } - }; - - const doLogout = async () => { - await axios.post('/logout'); - await checkAuth(); - }; - - useEffect(() => { - let timer = null; - axios - .get('/sanctum/csrf-cookie') - .then(() => { - checkAuth(); - timer = setInterval(checkAuth, 15 * 60 * 1000); - }); - return () => { - if (timer) clearInterval(timer); - }; - }, []); - - useEffect(() => { + React.useEffect(() => { window.Echo.channel('App.Control') .listen('PleaseRefresh', () => { location.reload(); @@ -51,18 +20,16 @@ const App = () => { }; }, []); - return - - - - - {t('general.appName')} - - - - - - ; + return + + + + {t('general.appName')} + + + + + ; }; export default App;