From c49f8d8c761f9d34d69599c7e6250e5e821db235 Mon Sep 17 00:00:00 2001 From: prayag17 Date: Mon, 3 Apr 2023 21:02:39 +0530 Subject: [PATCH] Add base for LibraryView --- src/App.jsx | 5 ++++ src/routes/home/root.jsx | 1 - src/routes/library/root.jsx | 51 ++++++++++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 3b34a47..7f5144b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -59,6 +59,8 @@ import { v4 as uuidv4 } from "uuid"; import { delServer, getServer } from "./utils/storage/servers.js"; import { getUser } from "./utils/storage/user.js"; +import { useDispatch } from "react-redux"; +import { showSidemenu } from "./utils/slice/sidemenu.js"; const jellyfin = new Jellyfin({ clientInfo: { name: "JellyPlayer", @@ -120,12 +122,15 @@ const AnimationWrapper = () => { function App() { const navigate = useNavigate(); + const dispatch = useDispatch(); + const [serverReachable, setServerReachable] = useState(true); const [checkingServer, setChecking] = useState(false); const createApi = async () => { const server = await getServer(); event.emit("create-jellyfin-api", server.Ip); + dispatch(showSidemenu()); }; const serverAvailable = async () => { diff --git a/src/routes/home/root.jsx b/src/routes/home/root.jsx index d3039ba..340c8b5 100644 --- a/src/routes/home/root.jsx +++ b/src/routes/home/root.jsx @@ -85,7 +85,6 @@ const Home = () => { const libraries = useQuery({ queryKey: ["home", "libraries"], queryFn: async () => { - dispatch(showSidemenu()); let libs = await getUserViewsApi(window.api).getUserViews({ userId: user.data.Id, }); diff --git a/src/routes/library/root.jsx b/src/routes/library/root.jsx index 04184dc..6839877 100644 --- a/src/routes/library/root.jsx +++ b/src/routes/library/root.jsx @@ -1,9 +1,58 @@ /** @format */ +import { useState, useEffect } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { showAppBar, setBackdrop } from "../../utils/slice/appBar"; import { useParams } from "react-router-dom"; +import Box from "@mui/material/Box"; +import useScrollTrigger from "@mui/material/useScrollTrigger"; + const LibraryView = () => { + const dispatch = useDispatch(); + const appBarVisiblity = useSelector((state) => state.appBar.visible); + + if (!appBarVisiblity) { + dispatch(showAppBar()); + } const { id } = useParams(); - return

{id}

; + const [scrollTarget, setScrollTarget] = useState(undefined); + + const trigger = useScrollTrigger({ + disableHysteresis: true, + threshold: 0, + target: scrollTarget, + }); + + useEffect(() => { + dispatch(setBackdrop(trigger)); + }, [trigger]); + + return ( + + { + if (node) { + setScrollTarget(node); + } + }} + > + {id} + + + ); }; export default LibraryView;