X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fapp%2Findex.js;fp=resources%2Fjs%2Fapp%2Findex.js;h=6a6b6c6bbda6f0184451cadefbe1ff74d7aa8528;hb=4c5a82cb876e96c72c50e8bc12bd8a43a9afe847;hp=fcc5311ec6404deaba12e4ed1c16c7f58b75b6f9;hpb=1e725fef6dc440aaeea8c30e1e0598dc5d24ad86;p=alttp.git diff --git a/resources/js/app/index.js b/resources/js/app/index.js index fcc5311..6a6b6c6 100644 --- a/resources/js/app/index.js +++ b/resources/js/app/index.js @@ -1,47 +1,17 @@ -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(); @@ -53,14 +23,14 @@ const App = () => { return - + {t('general.appName')} - - + + ; };