refactor: use suspense queries to fetch page data
This commit is contained in:
27 files changed
+2140
-1493
No files matched your search
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<!-- <script src="http://localhost:8097"></script> -->
|
<script src="http://localhost:8097"></script>
|
||||||
<title>Blink</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
.app-loading {
|
.app-loading {
|
||||||
|
|||||||
+29
-27
@@ -20,51 +20,51 @@
|
|||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.2.5",
|
"@fontsource-variable/jetbrains-mono": "^5.2.5",
|
||||||
"@fontsource-variable/noto-sans": "^5.2.6",
|
"@fontsource-variable/noto-sans": "^5.2.7",
|
||||||
"@fontsource-variable/plus-jakarta-sans": "^5.2.5",
|
"@fontsource-variable/plus-jakarta-sans": "^5.2.5",
|
||||||
"@fontsource-variable/space-grotesk": "^5.2.6",
|
"@fontsource-variable/space-grotesk": "^5.2.7",
|
||||||
"@jellyfin/sdk": "0.11.0",
|
"@jellyfin/sdk": "0.11.0",
|
||||||
"@million/lint": "^1.0.14",
|
"@million/lint": "^1.0.14",
|
||||||
"@mui/lab": "7.0.0-beta.11",
|
"@mui/lab": "7.0.0-beta.12",
|
||||||
"@mui/material": "7.0.2",
|
"@mui/material": "7.1.0",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@react-spring/web": "^9.7.5",
|
"@react-spring/web": "^10.0.1",
|
||||||
"@tanem/react-nprogress": "^5.0.55",
|
"@tanem/react-nprogress": "^5.0.55",
|
||||||
"@tanstack/react-form": "^1.7.0",
|
"@tanstack/react-form": "^1.11.2",
|
||||||
"@tanstack/react-query": "^5.74.4",
|
"@tanstack/react-query": "^5.76.1",
|
||||||
"@tanstack/react-query-devtools": "^5.74.6",
|
"@tanstack/react-query-devtools": "^5.76.1",
|
||||||
"@tanstack/react-router": "^1.117.1",
|
"@tanstack/react-router": "^1.120.5",
|
||||||
"@tanstack/react-router-devtools": "^1.117.1",
|
"@tanstack/react-router-devtools": "^1.120.6",
|
||||||
"@tanstack/react-virtual": "^3.13.6",
|
"@tanstack/react-virtual": "^3.13.9",
|
||||||
"@tauri-apps/api": "2.5.0",
|
"@tauri-apps/api": "2.5.0",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
||||||
"@tauri-apps/plugin-dialog": "2.2.1",
|
"@tauri-apps/plugin-dialog": "2.2.2",
|
||||||
"@tauri-apps/plugin-notification": "2.2.2",
|
"@tauri-apps/plugin-notification": "2.2.2",
|
||||||
"@tauri-apps/plugin-process": "2.2.1",
|
"@tauri-apps/plugin-process": "2.2.1",
|
||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-updater": "2.7.1",
|
"@tauri-apps/plugin-updater": "2.7.1",
|
||||||
"@tauri-apps/plugin-upload": "2.2.1",
|
"@tauri-apps/plugin-upload": "2.2.1",
|
||||||
"@tauri-apps/plugin-window-state": "~2.2.2",
|
"@tauri-apps/plugin-window-state": "~2.2.2",
|
||||||
"@types/node": "^22.15.2",
|
"@types/node": "^22.15.21",
|
||||||
"@types/react": "^19.1.2",
|
"@types/react": "^19.1.5",
|
||||||
"@types/react-dom": "^19.1.2",
|
"@types/react-dom": "^19.1.5",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"axios-tauri-api-adapter": "^2.0.6",
|
"axios-tauri-api-adapter": "^2.0.6",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"framer-motion": "^12.9.2",
|
|
||||||
"immer": "^10.1.1",
|
"immer": "^10.1.1",
|
||||||
"jassub": "^1.7.18",
|
"jassub": "^1.7.18",
|
||||||
"libpgs": "^0.8.1",
|
"libpgs": "^0.8.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"material-symbols": "^0.31.2",
|
"material-symbols": "^0.31.3",
|
||||||
"million": "^3.1.11",
|
"million": "^3.1.11",
|
||||||
|
"motion": "^12.12.1",
|
||||||
"notistack": "^3.0.2",
|
"notistack": "^3.0.2",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-error-boundary": "^5.0.0",
|
"react-error-boundary": "^6.0.0",
|
||||||
"react-intersection-observer": "^9.16.0",
|
"react-intersection-observer": "^9.16.0",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-multi-carousel": "^2.8.6",
|
"react-multi-carousel": "^2.8.6",
|
||||||
@@ -72,21 +72,23 @@
|
|||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"vite-plugin-svgr": "^4.3.0",
|
"vite-plugin-svgr": "^4.3.0",
|
||||||
"wavesurfer.js": "^7.9.4",
|
"wavesurfer.js": "^7.9.5",
|
||||||
"zustand": "5.0.3"
|
"zustand": "5.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
"@babel/plugin-proposal-optional-chaining-assign": "^7.27.1",
|
||||||
"@biomejs/biome": "^1.9.4",
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@tanstack/router-cli": "^1.117.1",
|
"@tanstack/router-cli": "^1.120.5",
|
||||||
"@tanstack/router-devtools": "^1.117.1",
|
"@tanstack/router-devtools": "^1.120.6",
|
||||||
"@tanstack/router-vite-plugin": "^1.117.2",
|
"@tanstack/router-vite-plugin": "^1.120.5",
|
||||||
"@tauri-apps/cli": "2.5.0",
|
"@tauri-apps/cli": "2.5.0",
|
||||||
"@types/lodash": "^4.17.16",
|
"@types/lodash": "^4.17.17",
|
||||||
"@vitejs/plugin-react": "^4.4.1",
|
"@vitejs/plugin-react": "^4.4.1",
|
||||||
|
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
||||||
|
"eslint-plugin-react-hooks": "6.0.0-rc1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"sass": "^1.87.0",
|
"sass": "^1.89.0",
|
||||||
"vite": "^6.3.3"
|
"vite": "^6.3.5"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
}
|
}
|
||||||
Generated
+1487
-831
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
|||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, { useLayoutEffect, useState } from "react";
|
import React, { useLayoutEffect, useState } from "react";
|
||||||
|
|
||||||
export default function Backdrop() {
|
export default function Backdrop() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import type { PanInfo } from "framer-motion";
|
import type { PanInfo } from "motion/react";
|
||||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
import type { MouseEvent, PointerEvent } from "react";
|
import type { MouseEvent, PointerEvent } from "react";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@@ -10,7 +10,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
|
|
||||||
import { AnimatePresence } from "framer-motion";
|
import { AnimatePresence } from "motion/react";
|
||||||
import "./audioPlayer.scss";
|
import "./audioPlayer.scss";
|
||||||
|
|
||||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, { useState, useMemo, useCallback } from "react";
|
import React, { useState, useMemo, useCallback } from "react";
|
||||||
|
|
||||||
import logo from "@/assets/logo.png";
|
import logo from "@/assets/logo.png";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Skeleton } from "@mui/material";
|
import { Skeleton } from "@mui/material";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
const ItemSkeleton = () => {
|
const ItemSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
+2
-2
@@ -43,8 +43,8 @@ const router = createRouter({
|
|||||||
defaultPreload: "intent",
|
defaultPreload: "intent",
|
||||||
defaultPreloadStaleTime: 0,
|
defaultPreloadStaleTime: 0,
|
||||||
defaultViewTransition: true,
|
defaultViewTransition: true,
|
||||||
// scrollRestoration: true,
|
scrollRestoration: true,
|
||||||
// scrollRestorationBehavior: "smooth",
|
scrollRestorationBehavior: "smooth",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register the router instance for type safety
|
// Register the router instance for type safety
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<AudioPlayer />
|
<AudioPlayer />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
<ReactQueryDevtools />
|
<ReactQueryDevtools />
|
||||||
<TanStackRouterDevtools />
|
{/* <TanStackRouterDevtools /> */}
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import Tabs from "@mui/material/Tabs";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import useParallax from "@/utils/hooks/useParallax";
|
||||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
import { AnimatePresence, motion, useScroll } from "motion/react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import useParallax from "@/utils/hooks/useParallax";
|
||||||
import { motion, useScroll } from "framer-motion";
|
import { motion, useScroll } from "motion/react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { green, red, yellow } from "@mui/material/colors";
|
|||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import useParallax from "@/utils/hooks/useParallax";
|
||||||
import { motion, useScroll } from "framer-motion";
|
import { motion, useScroll } from "motion/react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
|
|||||||
+81
-120
@@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo } from "react";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import "./home.scss";
|
import "./home.scss";
|
||||||
|
|
||||||
@@ -10,22 +10,22 @@ import Carousel from "@/components/carousel";
|
|||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
||||||
import { CardsSkeleton } from "@/components/skeleton/cards";
|
|
||||||
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
|
||||||
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
|
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
|
import CircularPageLoadingAnimation from "@/components/circularPageLoadingAnimation";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { getLatestItemsQueryOptions } from "@/utils/queries/items";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
@@ -36,58 +36,37 @@ import { ErrorBoundary } from "react-error-boundary";
|
|||||||
|
|
||||||
export const Route = createFileRoute("/_api/home/")({
|
export const Route = createFileRoute("/_api/home/")({
|
||||||
component: Home,
|
component: Home,
|
||||||
|
pendingComponent: () => <CircularPageLoadingAnimation />,
|
||||||
|
loader: ({ context: { api, user, queryClient } }) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
|
queryClient.ensureQueryData(getLatestItemsQueryOptions(api, user?.Id));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const libraries = useQuery({
|
const libraries = useSuspenseQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return;
|
if (!api || !user?.Id) return null;
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id && !!api?.accessToken,
|
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const latestMedia = useQuery({
|
const latestMedia = useSuspenseQuery(getLatestItemsQueryOptions(api, user?.Id));
|
||||||
queryKey: ["home", "latestMedia"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api) return;
|
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
|
||||||
userId: user?.Id,
|
|
||||||
fields: [
|
|
||||||
ItemFields.Overview,
|
|
||||||
ItemFields.ParentId,
|
|
||||||
ItemFields.SeasonUserData,
|
|
||||||
ItemFields.IsHd,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
],
|
|
||||||
includeItemTypes: [
|
|
||||||
BaseItemKind.Movie,
|
|
||||||
BaseItemKind.Series,
|
|
||||||
BaseItemKind.MusicAlbum,
|
|
||||||
],
|
|
||||||
enableUserData: true,
|
|
||||||
enableImages: true,
|
|
||||||
});
|
|
||||||
return media.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const resumeItemsVideo = useQuery({
|
const resumeItemsVideo = useSuspenseQuery({
|
||||||
queryKey: ["home", "resume", "video"],
|
queryKey: ["home", "resume", "video"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return;
|
if (!api || !user?.Id) return null;
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
mediaTypes: ["Video"],
|
mediaTypes: ["Video"],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
@@ -95,14 +74,12 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return resumeItems.data;
|
return resumeItems.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id,
|
|
||||||
refetchOnMount: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const resumeItemsAudio = useQuery({
|
const resumeItemsAudio = useSuspenseQuery({
|
||||||
queryKey: ["home", "resume", "audio"],
|
queryKey: ["home", "resume", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return;
|
if (!api || !user?.Id) return null;
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
@@ -112,13 +89,12 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return resumeItems.data;
|
return resumeItems.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const upNextItems = useQuery({
|
const upNextItems = useSuspenseQuery({
|
||||||
queryKey: ["home", "upNext"],
|
queryKey: ["home", "upNext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return;
|
if (!api || !user?.Id) return null;
|
||||||
const upNext = await getTvShowsApi(api).getNextUp({
|
const upNext = await getTvShowsApi(api).getNextUp({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
fields: [
|
fields: [
|
||||||
@@ -131,8 +107,6 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return upNext.data;
|
return upNext.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id,
|
|
||||||
refetchOnMount: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
|
||||||
@@ -154,37 +128,39 @@ function Home() {
|
|||||||
|
|
||||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
|
||||||
|
const setBackdropForItem = useCallback(
|
||||||
|
(item: BaseItemDto, api: Api) => {
|
||||||
|
if (item?.ParentBackdropImageTags) {
|
||||||
|
setBackdrop(
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Backdrop", {
|
||||||
|
tag: item.ParentBackdropImageTags[0],
|
||||||
|
}),
|
||||||
|
item.ParentBackdropImageTags[0] ?? item.Id,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setBackdrop(
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Backdrop", {
|
||||||
|
tag: item.BackdropImageTags?.[0],
|
||||||
|
}),
|
||||||
|
item.BackdropImageTags?.[0] ?? item.Id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[setBackdrop],
|
||||||
|
);
|
||||||
|
|
||||||
const handleOnChangeCarousel = useCallback(
|
const handleOnChangeCarousel = useCallback(
|
||||||
(now: number) => {
|
(now: number) => {
|
||||||
if (api && latestMedia.isSuccess && (latestMedia.data?.length ?? 0) > 0) {
|
if (api && latestMedia.isSuccess && (latestMedia.data?.length ?? 0) > 0) {
|
||||||
if (latestMedia.data?.[now]?.ParentBackdropImageTags) {
|
const currentItem = latestMedia.data?.[now];
|
||||||
setBackdrop(
|
if (!currentItem) return;
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
latestMedia.data[now].Id ?? "",
|
// Extract this logic to a separate function
|
||||||
"Backdrop",
|
setBackdropForItem(currentItem, api);
|
||||||
{
|
|
||||||
tag: latestMedia.data[now].ParentBackdropImageTags[0],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
latestMedia.data[now]?.ParentBackdropImageTags[0] ??
|
|
||||||
latestMedia.data[now].Id,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
setBackdrop(
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
latestMedia.data?.[now].Id ?? "",
|
|
||||||
"Backdrop",
|
|
||||||
{
|
|
||||||
tag: latestMedia.data?.[now].BackdropImageTags?.[0],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
latestMedia.data?.[now]?.BackdropImageTags?.[0] ??
|
|
||||||
latestMedia.data?.[now].Id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[latestMedia.data?.map((item) => item.Id).join("")],
|
// Only depend on what you need
|
||||||
|
[latestMedia.isSuccess, api, setBackdrop],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -196,15 +172,11 @@ function Home() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||||
{latestMedia.isPending ? (
|
{latestMedia.data?.length && (
|
||||||
<CarouselSkeleton />
|
<Carousel
|
||||||
) : (
|
content={latestMedia.data}
|
||||||
latestMedia.data?.length && (
|
onChange={handleOnChangeCarousel}
|
||||||
<Carousel
|
/>
|
||||||
content={latestMedia.data}
|
|
||||||
onChange={handleOnChangeCarousel}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
||||||
@@ -215,34 +187,29 @@ function Home() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{libraries.isPending ? (
|
<CardScroller displayCards={4} title="Libraries">
|
||||||
<CardsSkeleton />
|
{libraries.data?.Items?.map((item) => {
|
||||||
) : (
|
return (
|
||||||
<CardScroller displayCards={4} title="Libraries">
|
<Card
|
||||||
{libraries.status === "success" &&
|
key={item.Id}
|
||||||
libraries.data?.Items?.map((item) => {
|
item={item}
|
||||||
return (
|
cardTitle={item.Name}
|
||||||
<Card
|
imageType="Primary"
|
||||||
key={item.Id}
|
cardType="thumb"
|
||||||
item={item}
|
disableOverlay
|
||||||
cardTitle={item.Name}
|
onClick={() => {
|
||||||
imageType="Primary"
|
if (item.Id) {
|
||||||
cardType="thumb"
|
navigate({
|
||||||
disableOverlay
|
to: "/library/$id",
|
||||||
onClick={() => {
|
params: { id: item.Id },
|
||||||
if (item.Id) {
|
});
|
||||||
navigate({
|
}
|
||||||
to: "/library/$id",
|
}}
|
||||||
params: { id: item.Id },
|
overrideIcon={item.CollectionType}
|
||||||
});
|
/>
|
||||||
}
|
);
|
||||||
}}
|
})}
|
||||||
overrideIcon={item.CollectionType}
|
</CardScroller>
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={
|
fallback={
|
||||||
@@ -251,9 +218,7 @@ function Home() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{upNextItems.isPending ? (
|
{upNextItems.isSuccess && !upNextItems.data?.TotalRecordCount ? (
|
||||||
<CardsSkeleton />
|
|
||||||
) : upNextItems.isSuccess && !upNextItems.data?.TotalRecordCount ? (
|
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<CardScroller displayCards={4} title="Up Next">
|
<CardScroller displayCards={4} title="Up Next">
|
||||||
@@ -307,10 +272,8 @@ function Home() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{resumeItemsVideo.isPending ? (
|
{resumeItemsVideo.isSuccess &&
|
||||||
<CardsSkeleton />
|
!resumeItemsVideo.data?.TotalRecordCount ? (
|
||||||
) : resumeItemsVideo.isSuccess &&
|
|
||||||
!resumeItemsVideo.data?.TotalRecordCount ? (
|
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<CardScroller displayCards={4} title="Continue Watching">
|
<CardScroller displayCards={4} title="Continue Watching">
|
||||||
@@ -360,10 +323,8 @@ function Home() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{resumeItemsAudio.isPending ? (
|
{resumeItemsAudio.isSuccess &&
|
||||||
<CardsSkeleton />
|
!resumeItemsAudio.data?.TotalRecordCount ? (
|
||||||
) : resumeItemsAudio.isSuccess &&
|
|
||||||
!resumeItemsAudio.data?.TotalRecordCount ? (
|
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<CardScroller displayCards={4} title="Continue Listening">
|
<CardScroller displayCards={4} title="Continue Listening">
|
||||||
|
|||||||
@@ -10,16 +10,15 @@ import { green, red, yellow } from "@mui/material/colors";
|
|||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import useParallax from "@/utils/hooks/useParallax";
|
||||||
import { motion, useScroll } from "framer-motion";
|
import { motion, useScroll } from "motion/react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
MediaStreamType,
|
MediaStreamType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import heroBg from "@/assets/herobg.png";
|
import heroBg from "@/assets/herobg.png";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
@@ -61,11 +60,20 @@ import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
|||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/item/$id")({
|
export const Route = createFileRoute("/_api/item/$id")({
|
||||||
component: ItemDetail,
|
component: ItemDetail,
|
||||||
|
pendingComponent: () => <ItemSkeleton />,
|
||||||
|
// pendingMs: 5000,
|
||||||
|
loader: async ({ context: { queryClient, api, user }, params }) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
|
await queryClient.ensureQueryData(
|
||||||
|
getItemQueryOptions(params.id, api, user?.Id),
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function ItemDetail() {
|
function ItemDetail() {
|
||||||
@@ -75,25 +83,14 @@ function ItemDetail() {
|
|||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useSuspenseQuery(getItemQueryOptions(id, api, user?.Id));
|
||||||
queryKey: ["item", id],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api) return null;
|
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
networkMode: "always",
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const similarItems = useQuery({
|
const similarItems = useQuery({
|
||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return null;
|
if (!item.isSuccess) return null;
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
|
|
||||||
if (!item.data?.Id) return null;
|
if (!item.data?.Id) return null;
|
||||||
if (item.data?.Type === "Movie") {
|
if (item.data?.Type === "Movie") {
|
||||||
return (
|
return (
|
||||||
@@ -135,7 +132,6 @@ function ItemDetail() {
|
|||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
},
|
},
|
||||||
enabled: item.isSuccess,
|
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -321,11 +317,6 @@ function ItemDetail() {
|
|||||||
});
|
});
|
||||||
const parallax = useParallax(scrollYProgress, 50);
|
const parallax = useParallax(scrollYProgress, 50);
|
||||||
|
|
||||||
if (item.isPending || similarItems.isPending) {
|
|
||||||
return <ItemSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.isSuccess && item.data) {
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={id}
|
key={id}
|
||||||
@@ -877,7 +868,10 @@ function ItemDetail() {
|
|||||||
<Link
|
<Link
|
||||||
className="item-detail-cast-card"
|
className="item-detail-cast-card"
|
||||||
key={actor.Id}
|
key={actor.Id}
|
||||||
to={`/person/${actor.Id}`}
|
to="/person/$id"
|
||||||
|
params={{
|
||||||
|
id: actor.Id ?? "",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{actor.PrimaryImageTag ? (
|
{actor.PrimaryImageTag ? (
|
||||||
<img
|
<img
|
||||||
@@ -1073,10 +1067,6 @@ function ItemDetail() {
|
|||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (item.isError || similarItems.isError) {
|
|
||||||
return <ErrorNotice />;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ItemDetail;
|
export default ItemDetail;
|
||||||
+397
-453
@@ -17,7 +17,7 @@ import IconButton from "@mui/material/IconButton";
|
|||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||||
@@ -49,6 +49,7 @@ import type { AxiosResponse } from "axios";
|
|||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
import LibraryItemsSkeleton from "@/components/skeleton/libraryItems";
|
import LibraryItemsSkeleton from "@/components/skeleton/libraryItems";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
@@ -59,6 +60,12 @@ type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
|||||||
|
|
||||||
export const Route = createFileRoute("/_api/library/$id")({
|
export const Route = createFileRoute("/_api/library/$id")({
|
||||||
component: Library,
|
component: Library,
|
||||||
|
loader: async ({ context: { queryClient, api, user }, params }) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
|
await queryClient.ensureQueryData(
|
||||||
|
getLibraryQueryOptions(api, user.Id, params.id),
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function Library() {
|
function Library() {
|
||||||
@@ -68,20 +75,7 @@ function Library() {
|
|||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const currentLib = useQuery({
|
const currentLib = useSuspenseQuery(getLibraryQueryOptions(api, user?.Id, id));
|
||||||
queryKey: ["library", "currentLib", id],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api) return null;
|
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
networkMode: "always",
|
|
||||||
staleTime: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const genres = useQuery({
|
const genres = useQuery({
|
||||||
queryKey: ["library", "genreItem", id],
|
queryKey: ["library", "genreItem", id],
|
||||||
@@ -771,24 +765,6 @@ function Library() {
|
|||||||
}
|
}
|
||||||
}, [backdropItems]);
|
}, [backdropItems]);
|
||||||
|
|
||||||
if (items.isError) {
|
|
||||||
console.error(items.error);
|
|
||||||
}
|
|
||||||
if (currentLib.isPending) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
position: "fixed",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress size={72} thickness={1.4} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (currentLib.isSuccess) {
|
|
||||||
return (
|
return (
|
||||||
<main className="scrollY library padded-top">
|
<main className="scrollY library padded-top">
|
||||||
<div
|
<div
|
||||||
@@ -832,121 +808,386 @@ function Library() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="library-items">
|
<div className="library-items">
|
||||||
{currentLib.isSuccess && (
|
<div
|
||||||
<div
|
className={
|
||||||
className={
|
scrollTrigger
|
||||||
scrollTrigger
|
? "library-items-header glass scrolling"
|
||||||
? "library-items-header glass scrolling"
|
: "library-items-header"
|
||||||
: "library-items-header"
|
}
|
||||||
}
|
>
|
||||||
// padding={2}
|
<Stack
|
||||||
|
divider={<Divider flexItem orientation="vertical" />}
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
gap={1.2}
|
||||||
|
className="library-items-options"
|
||||||
>
|
>
|
||||||
<Stack
|
{!disableSort && sortBy && (
|
||||||
divider={<Divider flexItem orientation="vertical" />}
|
<div className="flex flex-row flex-center">
|
||||||
direction="row"
|
<IconButton
|
||||||
alignItems="center"
|
onClick={() => {
|
||||||
justifyContent="center"
|
sessionStorage.setItem(
|
||||||
gap={1.2}
|
`library-${currentLib.data?.Id}-config_sort`,
|
||||||
className="library-items-options"
|
JSON.stringify({
|
||||||
>
|
sortAscending: !sortAscending,
|
||||||
{!disableSort && sortBy && (
|
sortBy,
|
||||||
<div className="flex flex-row flex-center">
|
}),
|
||||||
<IconButton
|
);
|
||||||
onClick={() => {
|
setSortAscending((state: boolean) => !state);
|
||||||
sessionStorage.setItem(
|
}}
|
||||||
`library-${currentLib.data?.Id}-config_sort`,
|
>
|
||||||
JSON.stringify({
|
<span
|
||||||
sortAscending: !sortAscending,
|
className="material-symbols-rounded"
|
||||||
sortBy,
|
style={{
|
||||||
}),
|
transform: sortAscending
|
||||||
);
|
? "rotateX(0deg)"
|
||||||
setSortAscending((state: boolean) => !state);
|
: "rotateX(180deg)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
sort
|
||||||
className="material-symbols-rounded"
|
</span>
|
||||||
style={{
|
</IconButton>
|
||||||
transform: sortAscending
|
|
||||||
? "rotateX(0deg)"
|
|
||||||
: "rotateX(180deg)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
sort
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
<TextField
|
|
||||||
select
|
|
||||||
value={sortBy ?? "Name"}
|
|
||||||
size="small"
|
|
||||||
onChange={(e) => {
|
|
||||||
setSortBy(e.target.value);
|
|
||||||
console.info(e);
|
|
||||||
sessionStorage.setItem(
|
|
||||||
`library-${currentLib.data?.Id}-config_sort`,
|
|
||||||
JSON.stringify({
|
|
||||||
sortAscending,
|
|
||||||
sortBy: e.target.value,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{sortByOptions.map((item) => (
|
|
||||||
<MenuItem key={item.title} value={item.value}>
|
|
||||||
{item.title}
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</TextField>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{availableViewTypes.length > 0 && (
|
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
value={currentViewType}
|
value={sortBy ?? "Name"}
|
||||||
size="small"
|
size="small"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setCurrentViewType(e.target.value as BaseItemKind);
|
setSortBy(e.target.value);
|
||||||
|
console.info(e);
|
||||||
sessionStorage.setItem(
|
sessionStorage.setItem(
|
||||||
`library-${currentLib.data?.Id}-config_currentViewType`,
|
`library-${currentLib.data?.Id}-config_sort`,
|
||||||
e.target.value,
|
JSON.stringify({
|
||||||
|
sortAscending,
|
||||||
|
sortBy: e.target.value,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{availableViewTypes.map((item) => (
|
{sortByOptions.map((item) => (
|
||||||
<MenuItem key={item.value} value={item.value}>
|
<MenuItem key={item.title} value={item.value}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
)}
|
</div>
|
||||||
{!disableFilters && (
|
)}
|
||||||
<div>
|
{availableViewTypes.length > 0 && (
|
||||||
<Button
|
<TextField
|
||||||
startIcon={
|
select
|
||||||
<span className="material-symbols-rounded">
|
value={currentViewType}
|
||||||
filter_list
|
size="small"
|
||||||
</span>
|
onChange={(e) => {
|
||||||
}
|
setCurrentViewType(e.target.value as BaseItemKind);
|
||||||
size="large"
|
sessionStorage.setItem(
|
||||||
//@ts-ignore
|
`library-${currentLib.data?.Id}-config_currentViewType`,
|
||||||
color="white"
|
e.target.value,
|
||||||
onClick={handleFilterDropdown}
|
);
|
||||||
>
|
}}
|
||||||
Filter
|
>
|
||||||
</Button>
|
{availableViewTypes.map((item) => (
|
||||||
<Menu
|
<MenuItem key={item.value} value={item.value}>
|
||||||
open={filterMenuOpen}
|
{item.title}
|
||||||
anchorEl={filterButtonAnchorEl}
|
</MenuItem>
|
||||||
onClose={() => setFilterButtonAnchorEl(null)}
|
))}
|
||||||
slotProps={{
|
</TextField>
|
||||||
paper: {
|
)}
|
||||||
style: {
|
{!disableFilters && (
|
||||||
width: "28em",
|
<div>
|
||||||
maxHeight: "32em",
|
<Button
|
||||||
},
|
startIcon={
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
filter_list
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
size="large"
|
||||||
|
//@ts-ignore
|
||||||
|
color="white"
|
||||||
|
onClick={handleFilterDropdown}
|
||||||
|
>
|
||||||
|
Filter
|
||||||
|
</Button>
|
||||||
|
<Menu
|
||||||
|
open={filterMenuOpen}
|
||||||
|
anchorEl={filterButtonAnchorEl}
|
||||||
|
onClose={() => setFilterButtonAnchorEl(null)}
|
||||||
|
slotProps={{
|
||||||
|
paper: {
|
||||||
|
style: {
|
||||||
|
width: "28em",
|
||||||
|
maxHeight: "32em",
|
||||||
},
|
},
|
||||||
}}
|
},
|
||||||
>
|
}}
|
||||||
{currentViewType !== "Audio" && (
|
>
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={600}
|
||||||
|
mx="0.4em"
|
||||||
|
mb={0.5}
|
||||||
|
>
|
||||||
|
Filters
|
||||||
|
</Typography>
|
||||||
|
<FormControl
|
||||||
|
style={{
|
||||||
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.4em 1em",
|
||||||
|
borderRadius: "6px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.isPlayed}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isPlayed: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Played"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.isUnPlayed}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isUnPlayed: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Unplayed"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.isResumable}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isResumable: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Resumable"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.isFavorite}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isFavorite: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Favorites"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={600}
|
||||||
|
mx="0.4em"
|
||||||
|
mb={0.5}
|
||||||
|
>
|
||||||
|
Features
|
||||||
|
</Typography>
|
||||||
|
<FormControl
|
||||||
|
style={{
|
||||||
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.4em 1em",
|
||||||
|
borderRadius: "6px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.hasSubtitles}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasSubtitles: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Subtitles"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.hasTrailer}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasTrailer: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Trailer"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.hasSpecialFeature}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasSpecialFeature: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Special Features"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.hasThemeSong}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasThemeSong: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Theme Song"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.hasThemeVideo}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
hasThemeVideo: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Theme Video"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={600}
|
||||||
|
mx="0.4em"
|
||||||
|
mb={0.5}
|
||||||
|
>
|
||||||
|
Video Types
|
||||||
|
</Typography>
|
||||||
|
<FormControl
|
||||||
|
style={{
|
||||||
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.4em 1em",
|
||||||
|
borderRadius: "6px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={videoTypesState.BluRay}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setVideoTypesState((s) => ({
|
||||||
|
...s,
|
||||||
|
BluRay: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="BluRay"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={videoTypesState.Dvd}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setVideoTypesState((s) => ({
|
||||||
|
...s,
|
||||||
|
Dvd: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="DVD"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.isHD}
|
||||||
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) => {
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
isHD: e.target.checked,
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="HD"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={filters.is4K}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
is4K: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="4k"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={<Checkbox checked={false} />}
|
||||||
|
label="SD"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
value={filters.is3D}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFilters((s) => ({
|
||||||
|
...s,
|
||||||
|
is3D: e.target.checked,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="3D"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{genres.isSuccess &&
|
||||||
|
(genres.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<div>
|
<div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
@@ -954,7 +1195,7 @@ function Library() {
|
|||||||
mx="0.4em"
|
mx="0.4em"
|
||||||
mb={0.5}
|
mb={0.5}
|
||||||
>
|
>
|
||||||
Filters
|
Genres
|
||||||
</Typography>
|
</Typography>
|
||||||
<FormControl
|
<FormControl
|
||||||
style={{
|
style={{
|
||||||
@@ -964,325 +1205,32 @@ function Library() {
|
|||||||
borderRadius: "6px",
|
borderRadius: "6px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FormControlLabel
|
{genres.data?.Items?.map(
|
||||||
control={
|
(genre) =>
|
||||||
<Checkbox
|
genre.Id && (
|
||||||
checked={filters.isPlayed}
|
<FormControlLabel
|
||||||
onChange={(
|
key={genre.Id}
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
control={
|
||||||
) =>
|
<Checkbox
|
||||||
setFilters((s) => ({
|
checked={genreFilter.includes(genre.Id)}
|
||||||
...s,
|
onChange={(e) =>
|
||||||
isPlayed: e.target.checked,
|
handleGenreFilter(e, genre)
|
||||||
}))
|
}
|
||||||
}
|
/>
|
||||||
/>
|
}
|
||||||
}
|
label={genre.Name}
|
||||||
label="Played"
|
/>
|
||||||
/>
|
),
|
||||||
<FormControlLabel
|
)}
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.isUnPlayed}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
isUnPlayed: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Unplayed"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.isResumable}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
isResumable: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Resumable"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.isFavorite}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
isFavorite: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Favorites"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{currentViewType !== "Audio" && (
|
</Menu>
|
||||||
<div>
|
</div>
|
||||||
<Typography
|
)}
|
||||||
variant="h6"
|
</Stack>
|
||||||
fontWeight={600}
|
</div>
|
||||||
mx="0.4em"
|
|
||||||
mb={0.5}
|
|
||||||
>
|
|
||||||
Features
|
|
||||||
</Typography>
|
|
||||||
<FormControl
|
|
||||||
style={{
|
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
|
||||||
width: "100%",
|
|
||||||
padding: "0.4em 1em",
|
|
||||||
borderRadius: "6px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.hasSubtitles}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
hasSubtitles: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Subtitles"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.hasTrailer}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
hasTrailer: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Trailer"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.hasSpecialFeature}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
hasSpecialFeature: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Special Features"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.hasThemeSong}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
hasThemeSong: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Theme Song"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.hasThemeVideo}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
hasThemeVideo: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Theme Video"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{currentViewType !== "Audio" && (
|
|
||||||
<div>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={600}
|
|
||||||
mx="0.4em"
|
|
||||||
mb={0.5}
|
|
||||||
>
|
|
||||||
Video Types
|
|
||||||
</Typography>
|
|
||||||
<FormControl
|
|
||||||
style={{
|
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
|
||||||
width: "100%",
|
|
||||||
padding: "0.4em 1em",
|
|
||||||
borderRadius: "6px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={videoTypesState.BluRay}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setVideoTypesState((s) => ({
|
|
||||||
...s,
|
|
||||||
BluRay: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="BluRay"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={videoTypesState.Dvd}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setVideoTypesState((s) => ({
|
|
||||||
...s,
|
|
||||||
Dvd: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="DVD"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.isHD}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) => {
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
isHD: e.target.checked,
|
|
||||||
}));
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="HD"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={filters.is4K}
|
|
||||||
onChange={(
|
|
||||||
e: ChangeEvent<HTMLInputElement>,
|
|
||||||
) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
is4K: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="4k"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={<Checkbox checked={false} />}
|
|
||||||
label="SD"
|
|
||||||
disabled
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
value={filters.is3D}
|
|
||||||
onChange={(e) =>
|
|
||||||
setFilters((s) => ({
|
|
||||||
...s,
|
|
||||||
is3D: e.target.checked,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="3D"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{genres.isSuccess &&
|
|
||||||
(genres.data?.TotalRecordCount ?? 0) > 0 && (
|
|
||||||
<div>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={600}
|
|
||||||
mx="0.4em"
|
|
||||||
mb={0.5}
|
|
||||||
>
|
|
||||||
Genres
|
|
||||||
</Typography>
|
|
||||||
<FormControl
|
|
||||||
style={{
|
|
||||||
background: "rgb(0 0 0 / 0.4)",
|
|
||||||
width: "100%",
|
|
||||||
padding: "0.4em 1em",
|
|
||||||
borderRadius: "6px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{genres.data?.Items?.map(
|
|
||||||
(genre) =>
|
|
||||||
genre.Id && (
|
|
||||||
<FormControlLabel
|
|
||||||
key={genre.Id}
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={genreFilter.includes(
|
|
||||||
genre.Id,
|
|
||||||
)}
|
|
||||||
onChange={(e) =>
|
|
||||||
handleGenreFilter(e, genre)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={genre.Name}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</FormControl>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Menu>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{items.isPending ? (
|
{items.isPending ? (
|
||||||
<LibraryItemsSkeleton />
|
<LibraryItemsSkeleton />
|
||||||
) : items.data?.TotalRecordCount === 0 ? (
|
) : items.data?.TotalRecordCount === 0 ? (
|
||||||
@@ -1378,8 +1326,4 @@ function Library() {
|
|||||||
{items.isError && <ErrorNotice />}
|
{items.isError && <ErrorNotice />}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (currentLib.isError) {
|
|
||||||
return <ErrorNotice error={currentLib.error} />;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,9 @@
|
|||||||
grid-template-columns: repeat(var(--number-of-cols), minmax(0, 1fr));
|
grid-template-columns: repeat(var(--number-of-cols), minmax(0, 1fr));
|
||||||
justify-items: center;
|
justify-items: center;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
|
> * {
|
||||||
|
max-width: 11em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&-items {
|
&-items {
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
@@ -85,6 +88,11 @@
|
|||||||
grid-template-columns: repeat(auto-fit, minmax(10em, 1fr)) ;
|
grid-template-columns: repeat(auto-fit, minmax(10em, 1fr)) ;
|
||||||
gap: 1.6em;
|
gap: 1.6em;
|
||||||
padding: 1em 4.4em;
|
padding: 1em 4.4em;
|
||||||
|
align-content: center;
|
||||||
|
justify-items: center;
|
||||||
|
> .card {
|
||||||
|
max-width: 11em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-filter {
|
&-filter {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import Tab from "@mui/material/Tab";
|
|||||||
import Tabs from "@mui/material/Tabs";
|
import Tabs from "@mui/material/Tabs";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
|
||||||
import { BaseItemKind, LocationType } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind, LocationType } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import "./videoPlayer.scss";
|
|||||||
import { endsAt } from "@/utils/date/time";
|
import { endsAt } from "@/utils/date/time";
|
||||||
|
|
||||||
import { PlayMethod, RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
import { PlayMethod, RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import React, { type MouseEvent, useCallback, useMemo, useState } from "react";
|
import React, { type MouseEvent, useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import brokenImage from "/assetsStatic/broken-image.png?url";
|
import brokenImage from "/assetsStatic/broken-image.png?url";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { green, red, yellow } from "@mui/material/colors";
|
import { green, red, yellow } from "@mui/material/colors";
|
||||||
|
|
||||||
import useParallax from "@/utils/hooks/useParallax";
|
import useParallax from "@/utils/hooks/useParallax";
|
||||||
import { AnimatePresence, motion, useScroll } from "framer-motion";
|
import { AnimatePresence, motion, useScroll } from "motion/react";
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
|
|
||||||
|
|||||||
@@ -86,17 +86,6 @@ body {
|
|||||||
opacity: 0.35;
|
opacity: 0.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Page transitions
|
|
||||||
*/
|
|
||||||
:root{
|
|
||||||
view-transition-name: fadeingPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
::view-transition-group(fadeingPage) {
|
|
||||||
animation-duration: .3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fadeIn {
|
.fadeIn {
|
||||||
animation: 0.5s fadeInPage forwards;
|
animation: 0.5s fadeInPage forwards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { type MotionValue, useTransform } from "framer-motion";
|
import { type MotionValue, useTransform } from "motion/react";
|
||||||
|
|
||||||
export default function useParallax(
|
export default function useParallax(
|
||||||
value: MotionValue<number>,
|
value: MotionValue<number>,
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id itemId
|
||||||
|
* @param api api instance
|
||||||
|
* @param userId user's id
|
||||||
|
* @returns query options for the item
|
||||||
|
* @description This function returns the query options for the item. It uses the getUserLibraryApi to get the item data.
|
||||||
|
*/
|
||||||
|
export const getItemQueryOptions = (
|
||||||
|
id: string,
|
||||||
|
api: Api | null | undefined,
|
||||||
|
userId: string | null | undefined,
|
||||||
|
) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["item", id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !userId) {
|
||||||
|
throw Error("API or User ID is not defined");
|
||||||
|
}
|
||||||
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
|
userId: userId,
|
||||||
|
itemId: id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param api api instance
|
||||||
|
* @param userId user's id
|
||||||
|
* @returns query options for the latest items
|
||||||
|
* @description This function returns the query options for the latest items. It uses the getUserLibraryApi to get the latest items data.
|
||||||
|
*/
|
||||||
|
export const getLatestItemsQueryOptions = (
|
||||||
|
api: Api | null | undefined,
|
||||||
|
userId: string | null | undefined,
|
||||||
|
) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["home", "latestMedia"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !userId) {
|
||||||
|
throw Error("API or User ID is not defined");
|
||||||
|
}
|
||||||
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
|
userId: userId,
|
||||||
|
fields: [
|
||||||
|
ItemFields.Overview,
|
||||||
|
ItemFields.ParentId,
|
||||||
|
ItemFields.SeasonUserData,
|
||||||
|
ItemFields.IsHd,
|
||||||
|
ItemFields.MediaStreams,
|
||||||
|
ItemFields.MediaSources,
|
||||||
|
],
|
||||||
|
includeItemTypes: [
|
||||||
|
BaseItemKind.Movie,
|
||||||
|
BaseItemKind.Series,
|
||||||
|
BaseItemKind.MusicAlbum,
|
||||||
|
],
|
||||||
|
enableUserData: true,
|
||||||
|
enableImages: true,
|
||||||
|
});
|
||||||
|
return media.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param api Api instance
|
||||||
|
* @param userId user's id
|
||||||
|
* @param id library id
|
||||||
|
* @returns query options for the current library
|
||||||
|
*/
|
||||||
|
export const getLibraryQueryOptions = (
|
||||||
|
api: Api | null | undefined,
|
||||||
|
userId: string | null | undefined,
|
||||||
|
id: string,
|
||||||
|
) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["library", "currentLib", id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api || !userId) throw Error("API or User ID is not defined");
|
||||||
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
|
userId: userId,
|
||||||
|
itemId: id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
+5
-2
@@ -14,8 +14,11 @@ const plugins = [react({
|
|||||||
["@babel/plugin-proposal-optional-chaining-assign",
|
["@babel/plugin-proposal-optional-chaining-assign",
|
||||||
{
|
{
|
||||||
version: "2023-07"
|
version: "2023-07"
|
||||||
}]
|
}],
|
||||||
]
|
["babel-plugin-react-compiler", {
|
||||||
|
compilationMode: "annotation",
|
||||||
|
}],
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}), svgr(), TanStackRouterVite()];
|
}), svgr(), TanStackRouterVite()];
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|||||||
Reference in new issue
Block a user