import React, { useState, useEffect } from 'react'; import _ from 'lodash'; import settings from 'electron-settings'; import { ThemeProvider } from 'styled-components'; import { HashRouter as Router, Switch, Route } from 'react-router-dom'; import './styles/App.global.css'; import Layout from './components/layout/Layout'; import PlaylistList from './components/playlist/PlaylistList'; import PlaylistView from './components/playlist/PlaylistView'; import Config from './components/settings/Config'; import NowPlayingView from './components/player/NowPlayingView'; import Login from './components/settings/Login'; import StarredView from './components/starred/StarredView'; import Dashboard from './components/dashboard/Dashboard'; import PlayerBar from './components/player/PlayerBar'; import AlbumView from './components/library/AlbumView'; import ArtistView from './components/library/ArtistView'; import AlbumList from './components/library/AlbumList'; import ArtistList from './components/library/ArtistList'; import GenreList from './components/library/GenreList'; import { MockFooter } from './components/settings/styled'; import { useAppSelector } from './redux/hooks'; import PageModal from './components/modal/PageModal'; import NowPlayingMiniView from './components/player/NowPlayingMiniView'; import { GlobalContextMenu } from './components/shared/ContextMenu'; import SearchView from './components/search/SearchView'; import FolderList from './components/library/FolderList'; import { getTheme } from './shared/utils'; import { defaultDark } from './styles/styledTheme'; import { mockSettings } from './shared/mockSettings'; const App = () => { const [theme, setTheme] = useState(defaultDark); const [font, setFont] = useState('Poppins'); const misc = useAppSelector((state) => state.misc); useEffect(() => { const themes: any = process.env.NODE_ENV === 'test' ? mockSettings.themesDefault : _.concat(settings.getSync('themes'), settings.getSync('themesDefault')); setTheme(getTheme(themes, misc.theme) || defaultDark); }, [misc.theme]); useEffect(() => { setFont(misc.font); }, [misc.font]); if (!localStorage.getItem('server') || !localStorage.getItem('serverBase64')) { return ( } font={font}> ); } return ( } font={font}> ); }; export default App;