import { useEffect, useState } from 'react'; import { ToastContainer } from 'react-toastify'; import Background from 'features/background/Background'; import Widgets from 'features/misc/views/Widgets'; import Modals from 'features/misc/modals/Modals'; import { loadSettings, moveSettings } from 'utils/settings'; import EventBus from 'utils/eventbus'; import variables from 'config/variables'; const useAppSetup = () => { useEffect(() => { const firstRun = localStorage.getItem('firstRun'); const stats = localStorage.getItem('stats'); if (!firstRun || !stats) { moveSettings(); window.location.reload(); } loadSettings(); const refreshHandler = (data) => { if (data === 'other') { loadSettings(true); } }; EventBus.on('refresh', refreshHandler); variables.stats.tabLoad(); return () => { EventBus.off('refresh', refreshHandler); }; }, []); }; const App = () => { const [toastDisplayTime, setToastDisplayTime] = useState(2500); const [showBackground, setShowBackground] = useState(false); useEffect(() => { const storedToastDisplayTime = localStorage.getItem('toastDisplayTime'); const storedBackground = localStorage.getItem('background'); if (storedToastDisplayTime) { setToastDisplayTime(parseInt(storedToastDisplayTime, 10)); } if (storedBackground === 'true') { setShowBackground(true); } }, []); useAppSetup(); return ( <> {showBackground && }
); }; export default App;