diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx
index 75c9f81..fb1f9b1 100644
--- a/src/components/card/card.jsx
+++ b/src/components/card/card.jsx
@@ -3,7 +3,7 @@ import React from "react";
import PropTypes from "prop-types";
import Box from "@mui/material/Box";
-import Card from "@mui/material/Card";
+import MuiCard from "@mui/material/Card";
import CardContent from "@mui/material/CardContent";
import CardMedia from "@mui/material/CardMedia";
import CardActionArea from "@mui/material/CardActionArea";
@@ -18,7 +18,7 @@ import {
import { borderRadiusDefault } from "../../palette.module.scss";
import "./card.module.scss";
-export const CardLandscape = ({
+export const Card = ({
itemName,
itemId,
imageTags,
@@ -26,20 +26,24 @@ export const CardLandscape = ({
cardType = "",
subText = "",
playedPercent,
+ cardOrientation,
+ props,
}) => {
return (
-
{imageTags ? (
cardType == "thumb" ? (
@@ -54,7 +58,10 @@ export const CardLandscape = ({
alt={itemName}
sx={{
width: "100%",
- aspectRatio: 1.777,
+ aspectRatio:
+ cardOrientation == "landscape"
+ ? 1.777
+ : 0.666,
}}
className="card-image"
>
@@ -70,7 +77,10 @@ export const CardLandscape = ({
alt={itemName}
sx={{
width: "100%",
- aspectRatio: 1.777,
+ aspectRatio:
+ cardOrientation == "landscape"
+ ? 1.777
+ : 0.666,
}}
className="card-image"
>
@@ -94,7 +104,7 @@ export const CardLandscape = ({
left: "5%",
bottom: "5%",
borderRadius: "100px",
- height: 0.035,
+ height: "5px",
}}
/>
)}
@@ -130,44 +140,11 @@ export const CardLandscape = ({
-
+
);
};
-export const CardPotrait = ({ itemName, itemId, imageTags, iconType }) => {
- return (
-
-
- {imageTags ? (
-
- ) : (
-
- )}
-
- {MediaTypeIconCollectionCard[iconType]}
-
-
-
-
-
- {itemName}
-
-
-
- );
-};
-
-CardLandscape.propTypes = {
+Card.propTypes = {
itemName: PropTypes.string.isRequired,
itemId: PropTypes.string.isRequired,
imageTags: PropTypes.bool,
@@ -175,11 +152,5 @@ CardLandscape.propTypes = {
cardType: PropTypes.string,
subText: PropTypes.string || PropTypes.number,
playedPercent: PropTypes.number,
-};
-
-CardPotrait.propTypes = {
- itemName: PropTypes.string.isRequired,
- itemId: PropTypes.string.isRequired,
- imageTags: PropTypes.bool,
- iconType: PropTypes.string,
+ cardOrientation: PropTypes.string.isRequired,
};
diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss
index 1f287dd..295a6ea 100644
--- a/src/components/card/card.module.scss
+++ b/src/components/card/card.module.scss
@@ -1,7 +1,6 @@
/** @format */
.card {
- margin-right: 1em;
border-radius: $border-radius-default;
&.landscape {
diff --git a/src/components/homeSection/latestMediaSection.jsx b/src/components/homeSection/latestMediaSection.jsx
new file mode 100644
index 0000000..b480c5b
--- /dev/null
+++ b/src/components/homeSection/latestMediaSection.jsx
@@ -0,0 +1,72 @@
+/** @format */
+
+import { useQuery } from "@tanstack/react-query";
+import { CardScroller } from "../../components/cardScroller/cardScroller";
+import { Card } from "../../components/card/card";
+import { CardsSkeleton } from "../skeleton/cards";
+
+import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
+import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
+
+export const LatestMediaSection = ({ latestMediaLib }) => {
+ const user = useQuery({
+ queryKey: ["home", "user"],
+ queryFn: async () => {
+ let usr = await getUserApi(window.api).getCurrentUser();
+ return usr.data;
+ },
+ });
+ const fetchLatestMedia = async (library) => {
+ const media = await getUserLibraryApi(window.api).getLatestMedia({
+ userId: user.data.Id,
+ parentId: library,
+ limit: 16,
+ fields: ["PrimaryImageAspectRatio"],
+ });
+ return media.data;
+ };
+ const data = useQuery({
+ queryKey: ["homeSection, latestMedia", latestMediaLib],
+ queryFn: () => fetchLatestMedia(latestMediaLib[0]),
+ enabled: !!user.data,
+ });
+ if (data.isFetching) {
+ return ;
+ }
+ if (data.isSuccess && data.data.length >= 1) {
+ return (
+
+ {data.data.map((item, index) => {
+ return (
+
+ );
+ })}
+
+ );
+ }
+
+ return <>>;
+};
diff --git a/src/routes/home/root.jsx b/src/routes/home/root.jsx
index c30370e..aa51da3 100644
--- a/src/routes/home/root.jsx
+++ b/src/routes/home/root.jsx
@@ -1,8 +1,8 @@
/** @format */
-import { useState, useEffect } from "react";
+import { useState, useEffect, useLayoutEffect } from "react";
-import { Blurhash, BlurhashCanvas } from "react-blurhash";
+import { Blurhash } from "react-blurhash";
import { useQueryClient, useQuery } from "@tanstack/react-query";
@@ -26,8 +26,12 @@ import { yellow } from "@mui/material/colors";
import Carousel from "react-material-ui-carousel";
// Custom Components
-import { CardLandscape, CardPotrait } from "../../components/card/card";
+import { Card } from "../../components/card/card";
import { CardScroller } from "../../components/cardScroller/cardScroller";
+import { LatestMediaSection } from "../../components/homeSection/latestMediaSection";
+import { CarouselSkeleton } from "../../components/skeleton/carousel";
+import { CardsSkeleton } from "../../components/skeleton/cards";
+
// Icons
import { MediaTypeIconCollection } from "../../components/utils/iconsCollection.jsx";
import { MdiStarHalfFull } from "../../components/icons/mdiStarHalfFull";
@@ -43,12 +47,10 @@ 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 } from "react-router-dom";
+import { useNavigate, useLocation } from "react-router-dom";
import { formateDate } from "../../utils/date/formateDate";
import { getRuntime } from "../../utils/date/time";
-import { CarouselSkeleton } from "../../components/skeleton/carousel";
-import { CardsSkeleton } from "../../components/skeleton/cards";
const Home = () => {
const queryClient = useQueryClient();
@@ -147,89 +149,15 @@ const Home = () => {
enabled: !!user.data,
});
- const fetchLatestMedia = async (lib) => {
- const latmedia = useQuery({
- queryKey: ["home", "latestMedia", lib.name],
- queryFn: async () => {
- const media = await getUserLibraryApi(
- window.api,
- ).getLatestMedia({
- userId: user.data.Id,
- parentId: lib.parentId,
- limit: 16,
- });
- return media.data;
- },
- });
- return latmedia;
- };
-
- const [latestMediaContent, setLatestMediaContent] = useState([]);
- const [latestMediaLib, setLatestMediaLib] = useState("");
-
- // const latestMediaData = useQueries(latestMediaContent);
+ const [latestMediaLibs, setLatestMediaLibs] = useState([]);
const dispatch = useDispatch();
- const dataT = useSelector((state) => {
- state.sidebar.data;
- });
const navigate = useNavigate();
-
- const [layoutState, setLayoutState] = useState(null);
-
- const layout = [
- {
- type: "libs",
- name: "Libraries",
- data: libraries.data,
- // isLoading: libraries.isLoading,
- isLoading: false,
- },
- {
- type: "resumeVideo",
- name: "Continue Watching",
- data: resumeItemsVideo.data,
- // isLoading: resumeItemsVideo.isLoading,
- isLoading: false,
- },
- {
- type: "resumeAudio",
- name: "Continue Listnening",
- data: resumeItemsAudio.data,
- // isLoading: resumeItemsAudio.isLoading,
- isLoading: false,
- },
- {
- type: "nextup",
- name: "Next Up",
- data: upNextItems.data,
- // isLoading: upNextItems.isLoading,
- isLoading: false,
- },
- ];
-
- const latestMediaLayout = [];
+ const location = useLocation();
const excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
- const getLatestMedia = async () => {
- libraries.data.Items.map(async (lib) => {
- // console.log(lib);
- if (excludeTypes.includes(lib.CollectionType)) {
- return;
- } else {
- latestMediaLayout.push({
- type: "latestMedia",
- name: `Latest ${lib.Name}`,
- parentId: lib.Id,
- isLoading: false,
- });
- setLatestMediaContent(latestMediaLayout);
- }
- });
- };
-
const handleLogout = async () => {
console.log("Logging out user...");
await window.api.logout();
@@ -237,16 +165,24 @@ const Home = () => {
navigate("/login");
};
- useEffect(() => {
- if (libraries.isSuccess) {
- getLatestMedia();
- console.log(latestMediaContent);
- for (let lib of latestMediaContent) {
- console.log(lib);
- fetchLatestMedia(lib);
+ let tempData = [];
+ if (libraries.status == "success") {
+ libraries.data.Items.map((lib) => {
+ if (!excludeTypes.includes(lib.CollectionType)) {
+ tempData = latestMediaLibs;
+ if (
+ !tempData.some(
+ (el) =>
+ JSON.stringify(el) ==
+ JSON.stringify([lib.Id, lib.Name]),
+ )
+ ) {
+ tempData.push([lib.Id, lib.Name]);
+ setLatestMediaLibs(tempData);
+ }
}
- }
- }, []);
+ });
+ }
return (
<>
@@ -522,7 +458,7 @@ const Home = () => {
) : (
libraries.data.Items.map((item, index) => {
return (
- {
}
cardType="lib"
iconType={item.CollectionType}
- >
+ >
);
})
)}
@@ -546,7 +482,7 @@ const Home = () => {
{upNextItems.data.Items.map(
(item, index) => {
return (
- {
item.Name
: item.ProductionYear
}
- >
+ cardOrientation="landscape"
+ >
);
},
)}
@@ -593,7 +530,7 @@ const Home = () => {
{resumeItemsVideo.data.Items.map(
(item, index) => {
return (
- {
item.UserData
.PlayedPercentage
}
- >
+ cardOrientation="landscape"
+ >
);
},
)}
@@ -644,7 +582,7 @@ const Home = () => {
{resumeItemsAudio.data.Items.map(
(item, index) => {
return (
- {
item.UserData
.PlayedPercentage
}
- >
+ cardOrientation="landscape"
+ >
);
},
)}
)}
- {/*
-
- {" "}
- Libraries
-
-
- {userLibraries.map((library, index) => {
- // console.log(userLibraries);
- return (
-
- );
- })}
-
- */}
+ {latestMediaLibs.map((lib, index) => {
+ return (
+
+ );
+ })}
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 7e16783..ea5e6d1 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -1,4 +1,18 @@
/** @format */
+::-webkit-scrollbar {
+ width: 10px;
+ background: $clr-background-dark;
+}
+::-webkit-scrollbar-track {
+ background-color: transparent;
+ &:hover {
+ background: rgb(255 255 255 / 0.25);
+ }
+}
+::-webkit-scrollbar-thumb {
+ background: rgb(255 255 255 / 0.25);
+}
+
body {
font-family: "Open Sans";
background: $clr-background-default;