Clean up and typing
This commit is contained in:
21
src/App.tsx
21
src/App.tsx
@@ -4,7 +4,6 @@ import {
|
||||
createTheme,
|
||||
mergeMantineTheme,
|
||||
} from '@mantine/core';
|
||||
import { ModalsProvider } from '@mantine/modals';
|
||||
import { useCommonHooks, useQueryAPI } from 'hooks';
|
||||
import { useEffect } from 'react';
|
||||
import {
|
||||
@@ -20,6 +19,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
import './index.css';
|
||||
import { Homepage, Settings } from 'pages';
|
||||
import { ToastContainer } from 'react-toastify';
|
||||
import type { Theme, ThemePlaylist } from 'types';
|
||||
|
||||
function App() {
|
||||
const { data: allThemes, isFetched: isAllThemesFetched } = useQueryAPI({
|
||||
@@ -62,25 +62,28 @@ function App() {
|
||||
if (allThemes && themeName) {
|
||||
if (currentThemePlaylist === 'All') {
|
||||
if (themeName !== 'random') {
|
||||
const temp = allThemes.find((t: any) => t.name === themeName);
|
||||
const temp = allThemes.find((t: Theme) => t.name === themeName);
|
||||
setTheme(temp);
|
||||
} else {
|
||||
handleThemeChange(allThemes, false);
|
||||
}
|
||||
} else if (currentThemePlaylist === 'Time of Day') {
|
||||
const themeList = JSON.parse(
|
||||
themePlaylists.find((t: any) => t.name === currentThemePlaylist).themeList,
|
||||
themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
||||
.themeList,
|
||||
);
|
||||
setTheme(
|
||||
allThemes.find(
|
||||
(t: any) => t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||
(t: Theme) =>
|
||||
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
const themeList = JSON.parse(
|
||||
themePlaylists.find((t: any) => t.name === currentThemePlaylist).themeList,
|
||||
themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
||||
.themeList,
|
||||
);
|
||||
const filteredThemes = allThemes.filter((t: any) => themeList.includes(t.id));
|
||||
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
||||
setTheme('random');
|
||||
handleThemeChange(filteredThemes, false);
|
||||
}
|
||||
@@ -93,10 +96,8 @@ function App() {
|
||||
<MantineProvider theme={mantineTheme}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<ToastContainer />
|
||||
<ModalsProvider>
|
||||
<RouterProvider router={router} />
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
</ModalsProvider>
|
||||
<RouterProvider router={router} />
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
</ThemeProvider>
|
||||
</MantineProvider>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user