import React, { useEffect } from 'react' import ReactGA from 'react-ga' import { Provider, useDispatch } from 'react-redux' import { createHashHistory } from 'history' import { Admin as RAAdmin, Resource } from 'react-admin' import { HotKeys } from 'react-hotkeys' import dataProvider from './dataProvider' import authProvider from './authProvider' import { Layout, Login, Logout } from './layout' import transcoding from './transcoding' import player from './player' import user from './user' import song from './song' import album from './album' import artist from './artist' import playlist from './playlist' import { Player } from './audioplayer' import customRoutes from './routes' import { themeReducer, addToPlaylistDialogReducer, playerReducer, albumViewReducer, activityReducer, settingsReducer, } from './reducers' import createAdminStore from './store/createAdminStore' import { i18nProvider } from './i18n' import config from './config' import { setDispatch, startEventStream } from './eventStream' import { keyMap } from './hotkeys' import useChangeThemeColor from './useChangeThemeColor' const history = createHashHistory() if (config.gaTrackingId) { ReactGA.initialize(config.gaTrackingId) history.listen((location) => { ReactGA.pageview(location.pathname) }) ReactGA.pageview(window.location.pathname) } const App = () => ( ) const Admin = (props) => { useChangeThemeColor() const dispatch = useDispatch() useEffect(() => { if (config.devActivityPanel) { setDispatch(dispatch) authProvider .checkAuth() .then(() => startEventStream()) .catch(() => {}) // ignore if not logged in } }, [dispatch]) return ( {(permissions) => [ , , , , , , permissions === 'admin' ? ( ) : ( ), , , , , ]} ) } const AppWithHotkeys = () => ( ) export default AppWithHotkeys