Update LibraryPage #176

This commit is contained in:
Prayag Prajapati committed 2023-09-25 15:44:35 +05:30
1 parent 1e38aebb83
commit d4a923863d
3 files changed
+91 -70

No files matched your search

+1
View File
@@ -90,6 +90,7 @@ import axiosTauriApiAdapter from "axios-tauri-api-adapter";
const axiosClient = axios.create({ const axiosClient = axios.create({
adapter: axiosTauriApiAdapter, adapter: axiosTauriApiAdapter,
headers: { "Access-Control-Allow-Origin": "*" }, headers: { "Access-Control-Allow-Origin": "*" },
timeout: 4000,
}); });
const deviceId = localStorage.getItem("deviceId"); const deviceId = localStorage.getItem("deviceId");
+1 -1
View File
@@ -32,7 +32,7 @@ import { useBackdropStore } from "../../utils/store/backdrop";
import CarouselSlide from "../../components/carouselSlide"; import CarouselSlide from "../../components/carouselSlide";
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client"; import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
import ErrorBoundary from "../../components/errorBoundary"; import ErrorBoundary from "../../components/errorBoundary";
import { Typography } from "@mui/material"; import Typography from "@mui/material/Typography";
const Home = () => { const Home = () => {
const authUser = useQuery({ const authUser = useQuery({
+89 -69
View File
@@ -199,6 +199,7 @@ const LibraryView = () => {
useEffect(() => { useEffect(() => {
if (currentLib.isSuccess) { if (currentLib.isSuccess) {
if (currentLib.data.Items[0].CollectionType == "movies") { if (currentLib.data.Items[0].CollectionType == "movies") {
setCurrentViewType(BaseItemKind.Movie);
setViewType([ setViewType([
{ title: "Movies", value: BaseItemKind.Movie }, { title: "Movies", value: BaseItemKind.Movie },
{ title: "Collections", value: BaseItemKind.BoxSet }, { title: "Collections", value: BaseItemKind.BoxSet },
@@ -207,6 +208,7 @@ const LibraryView = () => {
{ title: "Studios", value: BaseItemKind.Studio }, { title: "Studios", value: BaseItemKind.Studio },
]); ]);
} else if (currentLib.data.Items[0].CollectionType == "music") { } else if (currentLib.data.Items[0].CollectionType == "music") {
setCurrentViewType(BaseItemKind.MusicAlbum);
setViewType([ setViewType([
{ title: "Albums", value: BaseItemKind.MusicAlbum }, { title: "Albums", value: BaseItemKind.MusicAlbum },
{ title: "Songs", value: BaseItemKind.Audio }, { title: "Songs", value: BaseItemKind.Audio },
@@ -216,17 +218,30 @@ const LibraryView = () => {
} else if ( } else if (
currentLib.data.Items[0].CollectionType == "tvshows" currentLib.data.Items[0].CollectionType == "tvshows"
) { ) {
setCurrentViewType(BaseItemKind.Series);
setViewType([ setViewType([
{ title: "Series", value: BaseItemKind.Series }, { title: "Series", value: BaseItemKind.Series },
{ title: "Actors", value: BaseItemKind.Person }, { title: "Actors", value: BaseItemKind.Person },
{ title: "Genres", value: BaseItemKind.Genre }, { title: "Genres", value: BaseItemKind.Genre },
{ title: "Networks", value: BaseItemKind.Studio }, { title: "Networks", value: BaseItemKind.Studio },
]); ]);
} else if (
currentLib.data.Items[0].CollectionType == "playlists"
) {
setCurrentViewType(BaseItemKind.PlaylistsFolder);
setViewType([
{
title: "Playlists",
value: BaseItemKind.PlaylistsFolder,
},
]);
} else { } else {
setCurrentViewType("none");
setViewType([]); setViewType([]);
} }
if (currentLib.data.Items[0].CollectionType == "movies") { if (currentLib.data.Items[0].CollectionType == "movies") {
setSortBy("SortName");
setSortByData([ setSortByData([
{ title: "Name", value: "SortName" }, { title: "Name", value: "SortName" },
{ title: "Critic Rating", value: "CriticRating" }, { title: "Critic Rating", value: "CriticRating" },
@@ -240,6 +255,7 @@ const LibraryView = () => {
} else if ( } else if (
currentLib.data.Items[0].CollectionType == "tvshows" currentLib.data.Items[0].CollectionType == "tvshows"
) { ) {
setSortBy("SortName");
setSortByData([ setSortByData([
{ title: "Name", value: "SortName" }, { title: "Name", value: "SortName" },
{ title: "Critic Rating", value: "CriticRating" }, { title: "Critic Rating", value: "CriticRating" },
@@ -250,6 +266,7 @@ const LibraryView = () => {
{ title: "Random", value: "Random" }, { title: "Random", value: "Random" },
]); ]);
} else if (currentLib.data.Items[0].CollectionType == "music") { } else if (currentLib.data.Items[0].CollectionType == "music") {
setSortBy("Name");
setSortByData([ setSortByData([
{ title: "Name", value: "Name" }, { title: "Name", value: "Name" },
{ title: "Album Artist", value: "AlbumArtist" }, { title: "Album Artist", value: "AlbumArtist" },
@@ -262,6 +279,7 @@ const LibraryView = () => {
{ title: "Random", value: "Random" }, { title: "Random", value: "Random" },
]); ]);
} else { } else {
setSortBy("SortName");
setSortByData([ setSortByData([
{ title: "Name", value: "SortName" }, { title: "Name", value: "SortName" },
{ title: "Critic Rating", value: "CriticRating" }, { title: "Critic Rating", value: "CriticRating" },
@@ -276,12 +294,6 @@ const LibraryView = () => {
} }
}, [currentLib.isSuccess]); }, [currentLib.isSuccess]);
useEffect(() => {
if (sortByData != undefined) {
setSortBy(sortByData[0].value);
}
}, [sortByData]);
const fetchLibItems = async (libraryId) => { const fetchLibItems = async (libraryId) => {
let result; let result;
if (currentViewType == "MusicArtist") { if (currentViewType == "MusicArtist") {
@@ -317,8 +329,8 @@ const LibraryView = () => {
currentLib.data.Items[0].CollectionType === currentLib.data.Items[0].CollectionType ===
"homevideos" || "homevideos" ||
currentLib.data.Items[0].Type === "Folder" || currentLib.data.Items[0].Type === "Folder" ||
(currentLib.data.Items[0].Type === currentLib.data.Items[0].Type === "CollectionFolder" ||
"CollectionFolder" && (currentLib.data.Items[0].Type != "boxsets" &&
!("CollectionType" in currentLib.data.Items[0])) !("CollectionType" in currentLib.data.Items[0]))
? undefined ? undefined
: true, : true,
@@ -360,32 +372,36 @@ const LibraryView = () => {
"currentLibItems", "currentLibItems",
id, id,
`page: ${page}`, `page: ${page}`,
[ {
currentViewType, currentViewType: currentViewType,
sortAscending: sortAscending,
sortAscending ? SortOrder.Ascending : SortOrder.Descending, sortBy: sortBy,
, playbackFilters: {
sortBy, isPlayed: isPlayed,
[ isUnPlayed: isUnPlayed,
isPlayed, isResumable: isResumable,
isUnPlayed, isFavorite: isFavorite,
isResumable, isLiked: isLiked,
isFavorite, isUnliked: isUnliked,
isLiked, },
isUnliked, extraFilters: {
], hasSubtitles: hasSubtitles,
[ hasTrailer: hasTrailer,
hasSubtitles, hasSpecialFeature: hasSpecialFeature,
hasTrailer, hasThemeSong: hasThemeSong,
hasSpecialFeature, hasThemeVideo: hasThemeVideo,
hasThemeSong, },
hasThemeVideo, qualityFIlters: {
], isBluRay: isBluRay,
[isBluRay, isDVD, isHD, is4K, is3D], isDVD: isDVD,
], isHD: isHD,
is4K: is4K,
is3D: is3D,
},
},
], ],
queryFn: () => fetchLibItems(id), queryFn: () => fetchLibItems(id),
enabled: currentLib.isSuccess, enabled: Boolean(currentViewType),
networkMode: "always", networkMode: "always",
}); });
@@ -393,12 +409,6 @@ const LibraryView = () => {
setCurrentViewType(e.target.value); setCurrentViewType(e.target.value);
}; };
useEffect(() => {
if (viewType.length != 0) {
setCurrentViewType(viewType[0].value);
}
}, [viewType]);
const disabledSortViews = [ const disabledSortViews = [
"MusicArtist", "MusicArtist",
"Person", "Person",
@@ -553,6 +563,7 @@ const LibraryView = () => {
transition={{ transition={{
duration: 0.2, duration: 0.2,
ease: "anticipate", ease: "anticipate",
delay: index * 0.02,
}} }}
> >
<Card <Card
@@ -601,37 +612,46 @@ const LibraryView = () => {
"currentLibItems", "currentLibItems",
id, id,
`page: ${page}`, `page: ${page}`,
[ {
currentViewType, currentViewType:
currentViewType,
sortAscending sortAscending:
? SortOrder.Ascending sortAscending,
: SortOrder.Descending, sortBy: sortBy,
, playbackFilters: {
sortBy, isPlayed:
[ isPlayed,
isPlayed, isUnPlayed:
isUnPlayed, isUnPlayed,
isResumable, isResumable:
isFavorite, isResumable,
isLiked, isFavorite:
isUnliked, isFavorite,
], isLiked: isLiked,
[ isUnliked:
hasSubtitles, isUnliked,
hasTrailer, },
hasSpecialFeature, extraFilters: {
hasThemeSong, hasSubtitles:
hasThemeVideo, hasSubtitles,
], hasTrailer:
[ hasTrailer,
isBluRay, hasSpecialFeature:
isDVD, hasSpecialFeature,
isHD, hasThemeSong:
is4K, hasThemeSong,
is3D, hasThemeVideo:
], hasThemeVideo,
], },
qualityFIlters: {
isBluRay:
isBluRay,
isDVD: isDVD,
isHD: isHD,
is4K: is4K,
is3D: is3D,
},
},
]} ]}
userId={user.data.Id} userId={user.data.Id}
imageBlurhash={ imageBlurhash={