|
|
|
@ -10,6 +10,7 @@ import { Icon } from './components/Icon.jsx'
|
|
|
|
|
import { Popup } from './components/Popup.jsx'
|
|
|
|
|
import { Toolbar } from './components/Toolbar.jsx'
|
|
|
|
|
import { OptionBar } from './components/OptionBar.jsx'
|
|
|
|
|
import { usePersistentState } from './utils.jsx'
|
|
|
|
|
|
|
|
|
|
window._ = _
|
|
|
|
|
window.dataBuffer = {}
|
|
|
|
@ -68,15 +69,15 @@ async function loadEventi(ids) {
|
|
|
|
|
|
|
|
|
|
const App = ({}) => {
|
|
|
|
|
// Data Sources
|
|
|
|
|
const [source, setSource] = useState('magistrale')
|
|
|
|
|
const [source, setSource] = usePersistentState('orario.source', 'magistrale')
|
|
|
|
|
const [eventi, setEventi] = useState([])
|
|
|
|
|
|
|
|
|
|
// View Modes
|
|
|
|
|
const [mode, setMode] = useState(MODE_COURSE)
|
|
|
|
|
const [mode, setMode] = usePersistentState('orario.mode', MODE_COURSE)
|
|
|
|
|
|
|
|
|
|
// Selection
|
|
|
|
|
const [selectedCourses, setSelectedCourses] = useState([])
|
|
|
|
|
const [hideOtherCourses, setHideOtherCourses] = useState(false)
|
|
|
|
|
const [selectedCourses, setSelectedCourses] = usePersistentState('orario.selection', [])
|
|
|
|
|
const [hideOtherCourses, setHideOtherCourses] = usePersistentState('orario.hide-other', false)
|
|
|
|
|
|
|
|
|
|
// Menus
|
|
|
|
|
const [helpVisible, setHelpVisible] = useState(false)
|
|
|
|
@ -99,19 +100,18 @@ const App = ({}) => {
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
selectedCourses.length === 0 ||
|
|
|
|
|
selectedCourses.filter(id => groupIds.has(id)).length === 0
|
|
|
|
|
(eventi.length > 0 && selectedCourses.filter(id => groupIds.has(id)).length === 0)
|
|
|
|
|
) {
|
|
|
|
|
setHideOtherCourses(false)
|
|
|
|
|
}
|
|
|
|
|
}, [eventi, selectedCourses.length])
|
|
|
|
|
|
|
|
|
|
const [theme, setTheme] = useState(
|
|
|
|
|
localStorage.getItem('theme') ??
|
|
|
|
|
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
|
|
|
const [theme, setTheme] = usePersistentState(
|
|
|
|
|
'orario.theme',
|
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
document.body.classList.toggle('dark-mode', theme === 'dark')
|
|
|
|
|
localStorage.setItem('theme', theme)
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|