From a08c51a00c3a54e74aabb78df097a978a983e5b6 Mon Sep 17 00:00:00 2001 From: prayag17 Date: Wed, 26 Apr 2023 16:51:47 +0530 Subject: [PATCH] Remove few bugs --- src-tauri/src/main.rs | 28 +++-- src/App.jsx | 3 +- src/components/appBar/appBar.jsx | 12 +-- src/components/menu/sidemenu.jsx | 2 +- src/routes/home/index.jsx | 17 +-- src/routes/item/index.jsx | 16 +-- src/routes/item/item.module.scss | 2 +- src/routes/library/index.jsx | 178 ++++++++++++++++--------------- src/store.js | 2 - src/utils/slice/appBar.js | 28 ----- 10 files changed, 117 insertions(+), 171 deletions(-) delete mode 100644 src/utils/slice/appBar.js diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a73f85f..e504181 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,25 +1,23 @@ -#![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" -)] +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use tauri::Manager; + // Create the command: // This command must be async so that it doesn't run on the main thread. #[tauri::command] async fn close_splashscreen(window: tauri::Window) { - // Close splashscreen - if let Some(splashscreen) = window.get_window("splashscreen") { - splashscreen.close().unwrap(); - } - // Show main window - window.get_window("main").unwrap().show().unwrap(); + // Close splashscreen + if let Some(splashscreen) = window.get_window("splashscreen") { + splashscreen.close().unwrap(); + } + // Show main window + window.get_window("main").unwrap().show().unwrap(); } fn main() { - tauri::Builder::default() - .invoke_handler(tauri::generate_handler![close_splashscreen]) - .plugin(tauri_plugin_store::Builder::default().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![close_splashscreen]) + .plugin(tauri_plugin_store::Builder::default().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/src/App.jsx b/src/App.jsx index fcfd2df..4d068ca 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -22,7 +22,7 @@ import { relaunch } from "@tauri-apps/api/process"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { useQuery } from "@tanstack/react-query"; -import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; +// import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; // Theming import CssBaseline from "@mui/material/CssBaseline"; @@ -398,7 +398,6 @@ function App() { - ); diff --git a/src/components/appBar/appBar.jsx b/src/components/appBar/appBar.jsx index 564a474..5418d36 100644 --- a/src/components/appBar/appBar.jsx +++ b/src/components/appBar/appBar.jsx @@ -17,7 +17,6 @@ import { theme } from "../../theme"; import { useDispatch, useSelector } from "react-redux"; import { useLocation, useNavigate } from "react-router-dom"; -import { hideBackButton } from "../../utils/slice/appBar"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { useQueryClient, useQuery } from "@tanstack/react-query"; @@ -34,10 +33,7 @@ export const AppBar = () => { const navigate = useNavigate(); const [display, setDisplay] = useState(false); - const backButtonVisible = useSelector( - (state) => state.appBar.backButtonVisible, - ); - const backdropVisible = useSelector((state) => state.appBar.backdrop); + const [backButtonVisible, setBackButtonVisible] = useState(true); const location = useLocation(); @@ -78,7 +74,9 @@ export const AppBar = () => { useEffect(() => { if (location.pathname == "/home") { - dispatch(hideBackButton()); + setBackButtonVisible(false); + } else { + setBackButtonVisible(true); } }, [location]); @@ -94,7 +92,7 @@ export const AppBar = () => { backgroundColor: "transparent", }} className={trigger ? "appBar backdropVisible" : "appBar"} - elevation={backdropVisible ? 6 : 0} + elevation={0} > { let usr = await getUserApi(window.api).getCurrentUser(); return usr.data; }, - enabled: false, + enabled: !!window.api, networkMode: "always", }); let libraries = useQuery({ diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index e09cb59..261e9d9 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -4,7 +4,7 @@ import { useState } from "react"; import { Blurhash } from "react-blurhash"; -import { useQueryClient, useQuery } from "@tanstack/react-query"; +import { useQuery } from "@tanstack/react-query"; import { EventEmitter as event } from "../../eventEmitter"; import { getServer } from "../../utils/storage/servers"; @@ -37,18 +37,14 @@ import { MdiStarHalfFull } from "../../components/icons/mdiStarHalfFull"; import { MdiPlayOutline } from "../../components/icons/mdiPlayOutline"; import { MdiChevronRight } from "../../components/icons/mdiChevronRight"; -import { useDispatch, useSelector } from "react-redux"; -import { showAppBar } from "../../utils/slice/appBar"; - import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; -import { useNavigate, useLocation } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; -import { formateDate } from "../../utils/date/formateDate"; import { getRuntime } from "../../utils/date/time"; const Home = () => { @@ -156,10 +152,7 @@ const Home = () => { const [latestMediaLibs, setLatestMediaLibs] = useState([]); - const dispatch = useDispatch(); - const navigate = useNavigate(); - const location = useLocation(); const excludeTypes = ["boxsets", "playlists", "livetv", "channels"]; @@ -191,12 +184,6 @@ const Home = () => { }); } - const appBarVisiblity = useSelector((state) => state.appBar.visible); - - if (!appBarVisiblity) { - dispatch(showAppBar()); - } - if (user.isPaused) { user.refetch(); console.log(user.isError); diff --git a/src/routes/item/index.jsx b/src/routes/item/index.jsx index f75c424..dc1ec60 100644 --- a/src/routes/item/index.jsx +++ b/src/routes/item/index.jsx @@ -28,7 +28,6 @@ import { green, pink } from "@mui/material/colors"; import { AvatarImage } from "../../components/avatar/avatar"; import { Blurhash } from "react-blurhash"; -import { showAppBar, showBackButton } from "../../utils/slice/appBar"; import { useDispatch, useSelector } from "react-redux"; import { useParams, useNavigate } from "react-router-dom"; @@ -97,17 +96,9 @@ const ItemDetail = () => { const { id } = useParams(); const dispatch = useDispatch(); const navigate = useNavigate(); - const appBarVisiblity = useSelector((state) => state.appBar.visible); const [primageImageLoaded, setPrimaryImageLoaded] = useState(false); const [backdropImageLoaded, setBackdropImageLoaded] = useState(false); - useEffect(() => { - if (!appBarVisiblity) { - dispatch(showAppBar()); - } - dispatch(showBackButton()); - }, []); - const user = useQuery({ queryKey: ["user"], queryFn: async () => { @@ -509,7 +500,7 @@ const ItemDetail = () => { > { )} {item.data.OriginalTitle} @@ -865,6 +856,7 @@ const ItemDetail = () => { + { const navigate = useNavigate(); - const dispatch = useDispatch(); - const appBarVisiblity = useSelector((state) => state.appBar.visible); const [page, setPage] = useState(1); const maxDisplayItems = 50; - if (!appBarVisiblity) { - dispatch(showAppBar()); - } const { id } = useParams(); const user = useQuery({ @@ -116,10 +109,6 @@ const LibraryView = () => { networkMode: "always", }); - if (currentLib.isSuccess) { - dispatch(showBackButton()); - } - const [isPlayed, setIsPlayed] = useState(false); const [isUnPlayed, setIsUnPlayed] = useState(false); const [isResumable, setIsResumable] = useState(false); @@ -405,7 +394,10 @@ const LibraryView = () => { }; useEffect(() => { - if (viewType.length != 0) setCurrentViewType(viewType[0].value); + if (viewType.length != 0) { + setCurrentViewType(viewType[0].value); + console.log(viewType); + } }, [viewType]); const disabledSortViews = [ @@ -809,84 +801,94 @@ const LibraryView = () => { currentViewType, ) && ( <> - {sortByData != undefined && ( - <> - - } - checkedIcon={ - - } - sx={{ - color: "white !important", - }} - color="white" - onChange={ - handleSortChange - } - checked={ - sortAscending - } - /> - - {sortByData.map( - ( - item, - index, - ) => { - return ( - - {`By ${item.title}`} - - ); - }, - )} - - - )} + {sortByData != undefined && + sortBy != undefined && ( + <> + + } + checkedIcon={ + + } + sx={{ + color: "white !important", + }} + color="white" + onChange={ + handleSortChange + } + checked={ + sortAscending + } + /> + + {sortByData.map( + ( + item, + index, + ) => { + return ( + + {`By ${item.title}`} + + ); + }, + )} + + + )} )} - {viewType.length != 0 && ( - - {viewType.map((item, index) => { - return ( - - {item.title} - - ); - })} - - )} + {viewType.length != 0 && + currentViewType != undefined && ( + + {viewType.map( + (item, index) => { + return ( + + { + item.title + } + + ); + }, + )} + + )} diff --git a/src/store.js b/src/store.js index 0854c89..bc185a1 100644 --- a/src/store.js +++ b/src/store.js @@ -2,10 +2,8 @@ import { configureStore } from "@reduxjs/toolkit"; import sideBarReducer from "./utils/slice/sidemenu"; -import appBarReducer from "./utils/slice/appBar"; export default configureStore({ reducer: { sidebar: sideBarReducer, - appBar: appBarReducer, }, }); diff --git a/src/utils/slice/appBar.js b/src/utils/slice/appBar.js deleted file mode 100644 index 03ea921..0000000 --- a/src/utils/slice/appBar.js +++ /dev/null @@ -1,28 +0,0 @@ -/** @format */ - -import { createSlice } from "@reduxjs/toolkit"; -export const appBarSlice = createSlice({ - name: "appBar", - initialState: { - visible: false, - backButtonVisible: false, - }, - reducers: { - showAppBar: (state) => { - state.visible = true; - }, - hideAppBar: (state) => { - state.visible = false; - }, - showBackButton: (state, action) => { - state.backButtonVisible = true; - }, - hideBackButton: (state) => { - state.backButtonVisible = false; - }, - }, -}); - -export const { showAppBar, hideAppBar, showBackButton, hideBackButton } = - appBarSlice.actions; -export default appBarSlice.reducer;