import React, { useState, useEffect } from 'react'; import Router from 'route-lite'; import { Fab, createMuiTheme, ThemeProvider, Snackbar } from '@material-ui/core'; import Create from './Create'; import Loading from './Loading'; import firebase from 'firebase/app'; import 'firebase/firestore'; import Inactive from './Inactive'; import { getUserUid } from './Api'; const APP_VERSION = '1.3.3'; const darkTheme = createMuiTheme({ palette: { type: 'dark', primary: { main: '#FF0000', }, secondary: { main: '#c0f300', }, }, }); const Routes = (props) => ( ); const wrongVersionStatus = { message: `Looks like Watch Party needs to update.\nGo to chrome://extensions to manually update.`, }; const App = () => { const closedNotification = { open: false, message: '' }; const [status, setStatus] = useState({ active: false, message: '' }); const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(false); const [notification, setNotification] = useState(closedNotification); useEffect(() => { setLoading(true); getUserUid(); firebase .firestore() .collection('server') .doc('status') .onSnapshot((statusSnap) => { setStatus(statusSnap.data()); setLoading(false); }); }, []); // HANDLE VISIBILITY STYLING const PartyRoutesWrapper = document.getElementById('party-routes-wrapper'); if (visible) { document.body.classList.add('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.add('visible'); } else { document.body.classList.remove('visible'); PartyRoutesWrapper && PartyRoutesWrapper.classList.remove('visible'); } // HANDLE FULLSCREEN EVENT document.onfullscreenchange = () => { if (document.fullscreenElement) setVisible(false); }; return ( setNotification(closedNotification)} message={notification.message} resumeHideDuration={1000} autoHideDuration={3000} /> {loading && } {status.active2 && status.version === APP_VERSION ? ( setNotification({ open: true, message })} /> ) : ( )} setVisible(!visible)} className="watch-party-fab"> ); }; export default App;