diff --git a/src/App.jsx b/src/App.jsx index 530d22b..73a36f3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -15,8 +15,6 @@ import { } from "react-router-dom"; import { AnimatePresence, motion } from "framer-motion"; -import { EventEmitter as event } from "./eventEmitter.js"; - import { relaunch } from "@tauri-apps/api/process"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; @@ -96,13 +94,8 @@ import ArtistTitlePage from "./routes/artist/index.jsx"; import EpisodeTitlePage from "./routes/episode/index.jsx"; import PlaylistTitlePage from "./routes/playlist/index.jsx"; -// Initial custom axios client to use tauri's http module -import axios from "axios"; -import axiosTauriApiAdapter from "axios-tauri-api-adapter"; import { createApi, useApi } from "./utils/store/api.js"; -import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api.js"; -import { Navigate } from "react-router-dom"; -import { useMutation, useQuery } from "@tanstack/react-query"; +import { useQuery } from "@tanstack/react-query"; import { CircularProgress } from "@mui/material"; const anim = { @@ -149,9 +142,9 @@ const LogicalRoute = () => { return res; }; if ( - !defaultServer.isLoading && - !server.isLoading && - !userSaved.isLoading + !defaultServer.isPending && + !server.isPending && + !userSaved.isPending ) { if (defaultServer.data) { if (userSaved.data) { @@ -237,21 +230,15 @@ const AnimationWrapper = () => { }; function App() { - const navigate = useNavigate(); - /** - * @type {[import("@jellyfin/sdk").Api, import("@jellyfin/sdk").Jellyfin]} + * @type {[import("@jellyfin/sdk").Api]} */ - const [api, jellyfin] = useApi((state) => [ - state.api, - state.createApi, - state.jellyfin, - ]); + const [api] = useApi((state) => [state.api]); - const [serverReachable, setServerReachable] = useState(true); + const [serverReachable] = useState(true); const [playbackDataLoading] = usePlaybackDataLoadStore((state) => [ - state.isLoading, + state.isPending, ]); const { enqueueSnackbar } = useSnackbar(); @@ -265,11 +252,6 @@ function App() { } }; - const LoginLogicalRoutes = () => { - // usersAvailable(); - return

/Login

; - }; - const handleRelaunch = async (event, reason) => { if (reason && reason == "backdropClick") { return; @@ -307,9 +289,7 @@ function App() { console.log(location); }, [location.key]); - const [audioPlayerVisible, currentAudioIndex] = useAudioPlayback( - (state) => [state.display, state.currentTrack], - ); + const [audioPlayerVisible] = useAudioPlayback((state) => [state.display]); const [backdropUrl, backdropId] = useBackdropStore((state) => [ state.backdropUrl, diff --git a/src/components/buttons/likeButton.jsx b/src/components/buttons/likeButton.jsx index a6f4abf..3cd9507 100644 --- a/src/components/buttons/likeButton.jsx +++ b/src/components/buttons/likeButton.jsx @@ -72,13 +72,13 @@ const LikeButton = ({ > { - if (!mutation.isLoading) { + if (!mutation.isPending) { e.stopPropagation(); mutation.mutate(); } @@ -92,7 +92,7 @@ const LikeButton = ({ display: "flex", alignItems: "center", justifyContent: "center", - opacity: mutation.isLoading ? 0.5 : 1, + opacity: mutation.isPending ? 0.5 : 1, }} > {isFavorite ? ( diff --git a/src/components/buttons/markPlayedButton.jsx b/src/components/buttons/markPlayedButton.jsx index 1f86145..670d036 100644 --- a/src/components/buttons/markPlayedButton.jsx +++ b/src/components/buttons/markPlayedButton.jsx @@ -64,13 +64,13 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { > { - if (!mutation.isLoading) { + if (!mutation.isPending) { e.stopPropagation(); mutation.mutate(); } @@ -84,7 +84,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { display: "flex", alignItems: "center", justifyContent: "center", - opacity: mutation.isLoading ? 0.5 : 1, + opacity: mutation.isPending ? 0.5 : 1, }} > state.setIsLoading, + (state) => state.setisPending, ); const { enqueueSnackbar } = useSnackbar(); diff --git a/src/components/layouts/homeSection/latestMediaSection.jsx b/src/components/layouts/homeSection/latestMediaSection.jsx index 10b74d3..33cfe53 100644 --- a/src/components/layouts/homeSection/latestMediaSection.jsx +++ b/src/components/layouts/homeSection/latestMediaSection.jsx @@ -38,7 +38,7 @@ export const LatestMediaSection = ({ latestMediaLib }) => { enabled: !!user.data, networkMode: "always", }); - if (data.isLoading) { + if (data.isPending) { return ; } if (data.isSuccess && data.data.length >= 1) { diff --git a/src/components/menu/sidemenu.jsx b/src/components/menu/sidemenu.jsx index da672ef..5910e13 100644 --- a/src/components/menu/sidemenu.jsx +++ b/src/components/menu/sidemenu.jsx @@ -140,7 +140,7 @@ export const SideMenu = () => { }} >
- {libraries.isLoading ? ( + {libraries.isPending ? ( <> ) : ( <> @@ -238,7 +238,7 @@ export const SideMenu = () => { - {libraries.isLoading ? ( + {libraries.isPending ? ( <> { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isPending || similarItems.isPending) { return ( { audioPlayButton cardType="square" /> - {musicTracks.isLoading ? ( + {musicTracks.isPending ? ( <> ) : ( musicTracks.data.TotalRecordCount > 0 && ( diff --git a/src/routes/artist/index.jsx b/src/routes/artist/index.jsx index 659540e..6fef2d0 100644 --- a/src/routes/artist/index.jsx +++ b/src/routes/artist/index.jsx @@ -159,9 +159,9 @@ const ArtistTitlePage = () => { } } }, [ - artistDiscography.isLoading, - artistSongs.isLoading, - artistAppearances.isLoading, + artistDiscography.isPending, + artistSongs.isPending, + artistAppearances.isPending, ]); const [animationDirection, setAnimationDirection] = useState("forward"); @@ -180,7 +180,7 @@ const ArtistTitlePage = () => { } }, [item.isSuccess]); - if (item.isLoading) { + if (item.isPending) { return ( { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isPending || similarItems.isPending) { return ( { } }, [item.isSuccess]); - if (item.isLoading) { + if (item.isPending) { return ( { }} > }> - {latestMedia.isLoading ? ( + {latestMedia.isPending ? ( ) : ( {
} > - {libraries.isLoading ? ( + {libraries.isPending ? ( ) : ( { } > - {upNextItems.isLoading ? ( + {upNextItems.isPending ? ( ) : upNextItems.isSuccess && upNextItems.data.Items.length == 0 ? ( @@ -373,7 +373,7 @@ const Home = () => { } > - {resumeItemsVideo.isLoading ? ( + {resumeItemsVideo.isPending ? ( ) : resumeItemsVideo.isSuccess && resumeItemsVideo.data.Items.length == 0 ? ( @@ -468,7 +468,7 @@ const Home = () => { } > - {resumeItemsAudio.isLoading ? ( + {resumeItemsAudio.isPending ? ( ) : resumeItemsAudio.isSuccess && resumeItemsAudio.data.Items.length == 0 ? ( diff --git a/src/routes/item/index.jsx b/src/routes/item/index.jsx index abaf56a..90e41a6 100644 --- a/src/routes/item/index.jsx +++ b/src/routes/item/index.jsx @@ -185,7 +185,7 @@ const ItemDetail = () => { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isPending || similarItems.isPending) { return ( { sx={{ mr: 2, flexShrink: 0 }} noWrap > - {currentLib.isLoading ? ( + {currentLib.isPending ? ( ) : ( currentLib.data.Items[0].Name @@ -383,7 +383,7 @@ const LibraryView = () => { ) : ( items.data.TotalRecordCount @@ -1247,7 +1247,7 @@ const LibraryView = () => { - {items.isLoading ? ( + {items.isPending ? ( { enabled: Boolean(api), }); - if (users.isLoading) { + if (users.isPending) { return ; } if (users.isSuccess) { @@ -407,7 +407,7 @@ export const UserLoginManual = () => { return ( <> - {server.isLoading && } + {server.isPending && } { justifyContent="center" alignItems="center" sx={{ - opacity: server.isLoading ? 0 : 1, + opacity: server.isPending ? 0 : 1, transition: "opacity 200ms", width: "100%", }} diff --git a/src/routes/person/index.jsx b/src/routes/person/index.jsx index ef6afe4..360709b 100644 --- a/src/routes/person/index.jsx +++ b/src/routes/person/index.jsx @@ -228,11 +228,11 @@ const PersonTitlePage = () => { } } }, [ - personMovies.isLoading, - personShows.isLoading, - personBooks.isLoading, - personPhotos.isLoading, - personEpisodes.isLoading, + personMovies.isPending, + personShows.isPending, + personBooks.isPending, + personPhotos.isPending, + personEpisodes.isPending, ]); const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); @@ -250,7 +250,7 @@ const PersonTitlePage = () => { } }, [item.isSuccess]); - if (item.isLoading) { + if (item.isPending) { return ( { onClick={handlePlayPrevEpisode} disabled={ seriesId - ? episodes.isLoading || + ? episodes.isPending || currentEpisodeIndex == 0 : true } @@ -770,7 +770,7 @@ export const VideoPlayer = () => { onClick={handlePlayNextEpisode} disabled={ seriesId - ? episodes.isLoading || + ? episodes.isPending || episodes.data ?.TotalRecordCount == currentEpisodeIndex + diff --git a/src/routes/playlist/index.jsx b/src/routes/playlist/index.jsx index cbe8694..38bc296 100644 --- a/src/routes/playlist/index.jsx +++ b/src/routes/playlist/index.jsx @@ -125,7 +125,7 @@ const PlaylistTitlePage = () => { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isPending || similarItems.isPending) { return ( { audioPlayButton cardType="square" /> - {musicTracks.isLoading ? ( + {musicTracks.isPending ? ( <> ) : ( musicTracks.data.TotalRecordCount > 0 && diff --git a/src/routes/search/index.jsx b/src/routes/search/index.jsx index 6f26a97..0a0aea3 100644 --- a/src/routes/search/index.jsx +++ b/src/routes/search/index.jsx @@ -198,13 +198,13 @@ const SearchPage = () => { Boolean( searchTerm, ) && - (movies.isLoading || - series.isLoading || - audio.isLoading || - musicAlbum.isLoading || - musicArtists.isLoading || - person.isLoading || - book.isLoading) + (movies.isPending || + series.isPending || + audio.isPending || + musicAlbum.isPending || + musicArtists.isPending || + person.isPending || + book.isPending) ? 1 : 0, }} diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index 9552fc6..2009c9d 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -211,7 +211,7 @@ const SeriesTitlePage = () => { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isPending || similarItems.isPending) { return ( { )} - {seasons.isLoading ? ( + {seasons.isPending ? ( ) : (
@@ -313,7 +313,7 @@ const SeriesTitlePage = () => { {
- {episodes.isLoading ? ( + {episodes.isPending ? ( ) : ( episodes.data.Items.map((episode) => { diff --git a/src/routes/setup/server/index.jsx b/src/routes/setup/server/index.jsx index 0de5297..e63b28a 100644 --- a/src/routes/setup/server/index.jsx +++ b/src/routes/setup/server/index.jsx @@ -88,7 +88,7 @@ export const ServerSetup = () => { top: 0, left: 0, right: 0, - opacity: checkServer.isLoading ? 1 : 0, + opacity: checkServer.isPending ? 1 : 0, transition: "opacity 350ms", }} /> @@ -96,7 +96,7 @@ export const ServerSetup = () => { maxWidth="sm" className={"centered serverContainer"} style={{ - opacity: checkServer.isLoading ? "0.5" : "1", + opacity: checkServer.isPending ? "0.5" : "1", transition: "opacity 350ms", }} > @@ -126,7 +126,7 @@ export const ServerSetup = () => { variant="contained" sx={{ width: "100%" }} size="large" - loading={checkServer.isLoading} + loading={checkServer.isPending} endIcon={ diff --git a/src/utils/store/playback.js b/src/utils/store/playback.js index 602d872..2fa8702 100644 --- a/src/utils/store/playback.js +++ b/src/utils/store/playback.js @@ -49,10 +49,10 @@ export const usePlaybackStore = create((set) => ({ })); export const usePlaybackDataLoadStore = create((set) => ({ - isLoading: false, - setIsLoading: (loading) => + isPending: false, + setisPending: (loading) => set((state) => ({ ...state, - isLoading: loading, + isPending: loading, })), }));