mirror of
https://github.com/mue/mue.git
synced 2026-07-09 13:35:35 +02:00
76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
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 && <Background />}
|
|
<ToastContainer
|
|
position="top-center"
|
|
autoClose={toastDisplayTime}
|
|
newestOnTop={true}
|
|
closeOnClick
|
|
pauseOnFocusLoss
|
|
/>
|
|
<div id="center">
|
|
<Widgets />
|
|
<Modals />
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|