diff --git a/.vscode/settings.json b/.vscode/settings.json index aa82e75..cabfd00 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,7 @@ }, "[json]": { "editor.defaultFormatter": "biomejs.biome" - } + }, + "rust-analyzer.linkedProjects": ["./src-tauri/Cargo.toml"], + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/biome.json b/biome.json index f42634a..3d94b67 100644 --- a/biome.json +++ b/biome.json @@ -1,19 +1,25 @@ { - "$schema": "https://biomejs.dev/schemas/1.5.0/schema.json", - "organizeImports": { - "enabled": true - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true, - "style": { - "noNonNullAssertion": "off" - } - } - }, - "files": { - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "*.json"], - "ignoreUnknown": true - } + "$schema": "https://biomejs.dev/schemas/1.5.0/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "style": { + "noNonNullAssertion": "off" + } + } + }, + "files": { + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.jsx", + "src/**/*.js", + "*.json" + ], + "ignoreUnknown": true + } } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 9c329a6..23f6252 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,7 +18,7 @@ tauri-build = { version = "1.5.1", features = [] } log = "^0.4.20" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.5.4", features = [ "updater", "http-all", "devtools", "process-exit", "process-relaunch", "shell-all", "window-set-fullscreen", "http-all"] } +tauri = { version = "1.5.4", features = [ "path-all", "updater", "http-all", "devtools", "process-exit", "process-relaunch", "shell-all", "window-set-fullscreen", "http-all"] } tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1", features = ["colored"] } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 65638fc..e548634 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -28,6 +28,9 @@ "all": true, "request": true, "scope": ["http://**", "http://*", "https://**", "https://*"] + }, + "path": { + "all": true } }, "bundle": { diff --git a/src/App.tsx b/src/App.tsx index 82a04ed..59a6398 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,5 @@ import React, { useState, useEffect } from "react"; -import useKonami from "react-use-konami"; - import { ThemeProvider } from "@mui/material/styles"; import { AnimatePresence, motion } from "framer-motion"; import { SnackbarProvider } from "notistack"; @@ -20,8 +18,6 @@ import { installUpdate, } from "@tauri-apps/api/updater"; -import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; - // Theming import CssBaseline from "@mui/material/CssBaseline"; import "./styles/global.scss"; @@ -52,7 +48,7 @@ import FavoritePage from "./routes/favorite/index.jsx"; import Home from "./routes/home"; import ItemDetail from "./routes/item"; import LibraryView from "./routes/library"; -import { LoginWithImage, UserLogin, UserLoginManual } from "./routes/login"; +import { LoginRoute, LoginWithImage, UserLogin, UserLoginManual } from "./routes/login"; import PersonTitlePage from "./routes/person/index.jsx"; import { VideoPlayer } from "./routes/player/videoPlayer.jsx"; import PlaylistTitlePage from "./routes/playlist/index.jsx"; @@ -93,7 +89,6 @@ import { ErrorNotice } from "./components/notices/errorNotice/errorNotice.jsx"; import AudioPlayer from "./components/playback/audioPlayer/index.jsx"; // Utils -import { useApi } from "./utils/store/api"; import { useAudioPlayback } from "./utils/store/audioPlayback.js"; import { useBackdropStore } from "./utils/store/backdrop.js"; import { useCentralStore } from "./utils/store/central.js"; @@ -101,45 +96,12 @@ import { usePlaybackDataLoadStore } from "./utils/store/playback.js"; // 3rd Party import { CircularProgress } from "@mui/material"; -import { useQuery } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import { useSnackbar } from "notistack"; import { ErrorBoundary } from "react-error-boundary"; - -const LoginRoute = () => { - const navigate = useNavigate(); - const [api] = useApi((state) => [state.api]); - - const usersList = useQuery({ - queryKey: ["public-users"], - queryFn: async () => { - const result = await getUserApi(api!).getPublicUsers(); - return result.data; - }, - enabled: Boolean(api), - }); - - if (usersList.isSuccess && !usersList.isFetching) { - if (usersList.data.length > 0) { - navigate("/login/users"); - } else { - navigate("/login/manual"); - } - } - - return ( -
- -
- ); -}; +import { EasterEgg } from "./components/utils/easterEgg.jsx"; +import { useKonamiEasterEgg } from "./utils/misc/konami"; +import { handleRelaunch } from "./utils/misc/relaunch"; // const anim = { // initial: { @@ -173,71 +135,35 @@ const LoginRoute = () => { // ); // }; -// const unlisten = await onUpdaterEvent(({ error, status }) => { -// // This will log all updater events, including status updates and errors. -// console.log("Updater event", error, status); -// }); - -// // you need to call unlisten if your handler goes out of scope, for example if the component is unmounted. -// unlisten(); - function App() { + const [audioPlayerVisible] = useAudioPlayback((state) => [state.display]); + const [easterEgg, setEasterEgg] = useKonamiEasterEgg(); + const { enqueueSnackbar } = useSnackbar(); + + const [initialRoute] = useCentralStore((state) => [state.initialRoute]); + const [backdropUrl, backdropId] = useBackdropStore((state) => [ + state.backdropUrl, + state.backdropId, + ]); const [playbackDataLoading] = usePlaybackDataLoadStore((state) => [ state.isPending, ]); - const handleRelaunch = async (_event: unknown, reason?: string) => { - if (reason && reason === "backdropClick") { - return; - } - await relaunch(); - }; - const location = useLocation(); + const navigate = useNavigate(); + + const [updateDialog, setUpdateDialog] = useState(false); + const [updateDialogButton, setUpdateDialogButton] = useState(false); + const [backdropLoading, setBackdropLoading] = useState(true); + const [updateInfo, setUpdateInfo] = useState( + undefined, + ); // biome-ignore lint/correctness/useExhaustiveDependencies: this dependency is required useEffect(() => { window.scrollTo(0, 0); }, [location.key]); - const [audioPlayerVisible] = useAudioPlayback((state) => [state.display]); - - const [backdropUrl, backdropId] = useBackdropStore((state) => [ - state.backdropUrl, - state.backdropId, - ]); - - const [backdropLoading, setBackdropLoading] = useState(true); - - const [easterEgg, setEasterEgg] = useState(false); - const sixtyNine = () => { - setEasterEgg(true); - }; - - useKonami(sixtyNine, { - code: [ - "ArrowUp", - "ArrowUp", - "ArrowDown", - "ArrowDown", - "ArrowLeft", - "ArrowRight", - "ArrowLeft", - "ArrowRight", - "b", - "a", - ], - }); - const { enqueueSnackbar } = useSnackbar(); - - const [updateDialog, setUpdateDialog] = useState(false); - - const [updateInfo, setUpdateInfo] = useState( - undefined, - ); - - const [updateDialogButton, setUpdateDialogButton] = useState(false); - useEffect(() => { async function checkForUpdates() { try { @@ -246,26 +172,16 @@ function App() { if (shouldUpdate) { setUpdateInfo(manifest); setUpdateDialog(true); - // You could show a dialog asking the user if they want to install the update here. + console.log(`Update found : ${manifest?.version}, ${manifest?.date}`); - - // Install the update. This will also restart the app on Windows! - // await installUpdate(); - - // On macOS and Linux you will need to restart the app manually. - // You could use this step to display another confirmation dialog. - // await relaunch(); } } catch (error) { console.error(error); } } checkForUpdates(); - }, []); + }); - const [initialRoute] = useCentralStore((state) => [state.initialRoute]); - - const navigate = useNavigate(); if (!initialRoute) { return (
); } - if (initialRoute) { - return ( - - - {playbackDataLoading && ( - - )} - - {updateInfo !== undefined && ( - <> - - Update Available! - - v{updateInfo.version} - - - - - {updateInfo.body} - - - + + {playbackDataLoading && ( + + )} + + {updateInfo !== undefined && ( + <> + + Update Available! + - - - - Update - - - - - - { - setUpdateDialogButton(true); - await installUpdate(); - enqueueSnackbar( - "Update has been installed! You need to relaunch JellyPlayer.", - { - variant: "success", - }, - ); - await relaunch(); - }} - > - Update - - - - )} - - setEasterEgg(false)} - sx={{ - background: "black", - }} - > -