diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx
index 0f31df1..8ce36be 100644
--- a/src/components/card/card.jsx
+++ b/src/components/card/card.jsx
@@ -2,6 +2,10 @@
import React from "react";
import PropTypes from "prop-types";
+import Card from "@mui/material/Card";
+import CardContent from "@mui/material/CardContent";
+import CardMedia from "@mui/material/CardMedia";
+import CardActionArea from "@mui/material/CardActionArea";
import Typography from "@mui/material/Typography";
import {
@@ -13,43 +17,43 @@ import "./card.module.scss";
export const CardLandscape = ({ itemName, itemId, imageTags, iconType }) => {
const imageAvailable = () => {
- console.log(imageTags);
- if (imageTags == undefined) {
- console.log("hee");
+ if (imageTags == {}) {
return false;
} else {
+ console.log("hee");
return true;
}
};
+ console.log(!!imageTags.Primary);
return (
-
-
- {imageAvailable ? (
-
+
+
+ {imageTags ? (
+
) : (
-
+
+ {MediaCollectionTypeIconCollectionCard[iconType]}
+
)}
-
- {MediaCollectionTypeIconCollectionCard[iconType]}
-
-
-
-
- {itemName}
-
-
-
+
+
+ {itemName}
+
+
+
+
);
};
diff --git a/src/components/cardScroller/cardScroller.jsx b/src/components/cardScroller/cardScroller.jsx
index a0b22dc..f8f53dd 100644
--- a/src/components/cardScroller/cardScroller.jsx
+++ b/src/components/cardScroller/cardScroller.jsx
@@ -1,6 +1,6 @@
/** @format */
-import { useRef, useEffect } from "react";
+import { useState, useEffect } from "react";
import PropTypes from "prop-types";
import Carousel from "react-multi-carousel";
@@ -10,41 +10,13 @@ import { MdiChevronLeft } from "../icons/mdiChevronLeft";
import { MdiChevronRight } from "../icons/mdiChevronRight";
import { styled } from "@mui/material/styles";
-import Button from "@mui/material/Button";
+import IconButton from "@mui/material/IconButton";
+import Box from "@mui/material/Box";
+import Typography from "@mui/material/Typography";
import ButtonGroup from "@mui/material/ButtonGroup";
import "./cardScroller.module.scss";
-
-const CarouselButton = styled(Button)(() => ({
- color: "white",
- height: "100%",
-}));
-
-const SliderButtonRight = ({ onClick }) => {
- return (
- onClick()}
- className="card-scroller-button right"
- variant="text"
- >
-
-
- );
-};
-
-const SliderButtonLeft = ({ onClick }) => {
- return (
- onClick()}
- className="card-scroller-button left"
- variant="text"
- >
-
-
- );
-};
-
-export const CardScroller = ({ children, displayCards }) => {
+export const CardScroller = ({ children, displayCards, title }) => {
const responsive = {
desktop: {
breakpoint: { max: 3000, min: 1024 },
@@ -63,21 +35,51 @@ export const CardScroller = ({ children, displayCards }) => {
},
};
+ const [carouselRef, setCarouselRef] = useState();
+
return (
- }
- customLeftArrow={}
- className="card-scroller"
- >
- {children}
-
+
+
+
+ {" "}
+ {title}
+
+
+ carouselRef.previous()}
+ >
+
+
+ carouselRef.next()}
+ >
+
+
+
+
+ setCarouselRef(el)}
+ // customButtonGroup={}
+ // renderButtonGroupOutside={true}
+ className="card-scroller"
+ >
+ {children}
+
+
);
};
CardScroller.propTypes = {
displayCards: PropTypes.number.isRequired,
+ title: PropTypes.string.isRequired,
};
diff --git a/src/components/cardScroller/cardScroller.module.scss b/src/components/cardScroller/cardScroller.module.scss
index c4a7b93..f6ff96a 100644
--- a/src/components/cardScroller/cardScroller.module.scss
+++ b/src/components/cardScroller/cardScroller.module.scss
@@ -7,23 +7,25 @@
display: flex;
}
&-button {
- color: white;
- position: absolute !important;
- top: 49%;
- transform: translateY(-50%);
- background-color: $clr-background-dark !important;
- border-radius: $border-radius-intensity-1 !important;
- opacity: 0;
- transition: opacity $transition-time-default !important;
- &:hover,
- &:focus {
- opacity: 1;
- }
- &.right {
- right: 0%;
- }
- &.left {
- left: 0%;
+ aspect-ratio: 1;
+ }
+ &-header-container {
+ display: flex;
+ width: 100%;
+ justify-content: space-between;
+ align-items: center;
+ }
+ &-heading {
+ display: flex;
+ align-items: center;
+ justify-content: flex-start;
+ gap: 0.35em;
+ position: relative;
+ margin-bottom: 0.25em !important;
+ &-decoration {
+ width: 0.75em;
+ height: 3px;
+ background: white;
}
}
}
diff --git a/src/components/skeleton/carousel.jsx b/src/components/skeleton/carousel.jsx
new file mode 100644
index 0000000..244a68f
--- /dev/null
+++ b/src/components/skeleton/carousel.jsx
@@ -0,0 +1,42 @@
+/** @format */
+import Skeleton from "@mui/material/Skeleton";
+import Paper from "@mui/material/Paper";
+import Box from "@mui/material/Box";
+import Typography from "@mui/material/Typography";
+import { theme } from "../../theme";
+export const CarouselSkeleton = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/src/routes/home/home.module.scss b/src/routes/home/home.module.scss
index 7eb89a9..1ab8274 100644
--- a/src/routes/home/home.module.scss
+++ b/src/routes/home/home.module.scss
@@ -89,19 +89,3 @@
border-radius: 0;
}
}
-
-.home-section {
- &-heading {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- gap: 0.35em;
- position: relative;
- margin-bottom: 0.25em !important;
- &-decoration {
- width: 0.75em;
- height: 3px;
- background: white;
- }
- }
-}
diff --git a/src/routes/home/root.jsx b/src/routes/home/root.jsx
index d0542e7..71eedda 100644
--- a/src/routes/home/root.jsx
+++ b/src/routes/home/root.jsx
@@ -38,11 +38,13 @@ import { showSidemenu } from "../../utils/slice/sidemenu";
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
-import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-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 { formateDate } from "../../utils/date/formateDate";
import { getRuntime } from "../../utils/date/time";
+import { CarouselSkeleton } from "../../components/skeleton/carousel";
export const Home = () => {
const queryClient = useQueryClient();
@@ -97,6 +99,48 @@ export const Home = () => {
enabled: !!user.data,
});
+ const resumeItemsVideo = useQuery({
+ queryKey: ["home", "resume", "video"],
+ queryFn: async () => {
+ const resumeItems = await getItemsApi(window.api).getResumeItems(
+ {
+ userId: user.data.Id,
+ limit: 16,
+ mediaTypes: ["Video"],
+ },
+ );
+ return resumeItems.data;
+ },
+ enabled: !!user.data,
+ });
+
+ const resumeItemsAudio = useQuery({
+ queryKey: ["home", "resume", "audio"],
+ queryFn: async () => {
+ const resumeItems = await getItemsApi(window.api).getResumeItems(
+ {
+ userId: user.data.Id,
+ limit: 16,
+ mediaTypes: ["Audio"],
+ },
+ );
+ return resumeItems.data;
+ },
+ enabled: !!user.data,
+ });
+
+ const upNextItems = useQuery({
+ queryKey: ["home", "upNext"],
+ queryFn: async () => {
+ const upNext = await getTvShowsApi(window.api).getNextUp({
+ userId: user.data.Id,
+ limit: 16,
+ });
+ return upNext.data;
+ },
+ enabled: !!user.data,
+ });
+
const [userLibraries, setUserLibraries] = useState([]);
const [latestMovies, setLatestMovies] = useState([]);
const [Auser, setUser] = useState({
@@ -109,14 +153,78 @@ export const Home = () => {
});
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 excludeTypes = ["boxsets", "playlists", "livetv", "channels"];
+ const getLatestMedia = async () => {
+ libraries.data.Items.map(async (lib) => {
+ // console.log(lib);
+ if (excludeTypes.includes(lib.CollectionType)) {
+ return;
+ } else {
+ let latmedia = await getUserLibraryApi(
+ window.api,
+ ).getLatestMedia({
+ userId: user.data.Id,
+ parentId: lib.Id,
+ limit: 16,
+ });
+ layout.push({
+ type: "latestMedia",
+ name: `Latest ${lib.Name}`,
+ data: latmedia.data,
+ isLoading: false,
+ });
+ }
+ });
+ };
+
const handleLogout = async () => {
await window.api.logout();
navigate("/login");
console.log("logged out user");
};
+ useEffect(() => {
+ if (libraries.isSuccess) {
+ getLatestMedia();
+ setLayoutState(layout);
+ }
+ }, []);
+
return (
<>
{
display: "flex",
}}
>
- {/*
-
-
-
-
-
-
-
-
- {userLibraries.map((library, index) => {
- return (
-
-
-
- {
- MediaCollectionTypeIconCollection[
- library
- .CollectionType
- ]
- }
-
-
-
-
- );
- })}
-
- */}
{
interval={10000}
>
{latestMedia.isLoading ? (
-
-
-
-
-
-
-
-
-
-
-
-
-
+
) : (
// <>>
latestMedia.data != null &&
@@ -465,8 +469,25 @@ export const Home = () => {
})
)}
+
+ {libraries.isLoading == false &&
+ libraries.data.Items.map((item, index) => {
+ return (
+
+ );
+ })}
+
-
+ {/*
{
);
})}
-
-
-
-
- {" "}
- Latest Movies
-
-
- {latestMovies.map((movie, index) => {
- return (
-
- );
- })}
-
-
-
+ */}
@@ -525,3 +521,69 @@ export const Home = () => {
>
);
};
+
+/*
+
+
+
+
+
+
+
+
+ {userLibraries.map((library, index) => {
+ return (
+
+
+
+ {
+ MediaCollectionTypeIconCollection[
+ library
+ .CollectionType
+ ]
+ }
+
+
+
+
+ );
+ })}
+
+ */
diff --git a/src/store.js b/src/store.js
index fd31d01..7459098 100644
--- a/src/store.js
+++ b/src/store.js
@@ -2,9 +2,11 @@
import { configureStore } from "@reduxjs/toolkit";
import sideBarReducer from "./utils/slice/sidemenu";
+import homePageReducer from "./utils/slice/homePage";
export default configureStore({
reducer: {
sidebar: sideBarReducer,
+ homePage: homePageReducer,
},
});
diff --git a/src/utils/slice/homePage.js b/src/utils/slice/homePage.js
new file mode 100644
index 0000000..a875d38
--- /dev/null
+++ b/src/utils/slice/homePage.js
@@ -0,0 +1,63 @@
+/** @format */
+
+import { createSlice } from "@reduxjs/toolkit";
+
+export const homePageSlice = createSlice({
+ name: "homePage",
+ initialState: [
+ {
+ type: "libs",
+ name: "Libraries",
+ data: [],
+ // isLoading: libraries.isLoading,
+ isLoading: false,
+ },
+ {
+ type: "resumeVideo",
+ name: "Continue Watching",
+ data: [],
+ // isLoading: resumeItemsVideo.isLoading,
+ isLoading: false,
+ },
+ {
+ type: "resumeAudio",
+ name: "Continue Listnening",
+ data: [],
+ // isLoading: resumeItemsAudio.isLoading,
+ isLoading: false,
+ },
+ {
+ type: "nextup",
+ name: "Next Up",
+ data: [],
+ // isLoading: upNextItems.isLoading,
+ isLoading: false,
+ },
+ ],
+ reducers: {
+ setData: (state, action) => {
+ switch (action.payload[0]) {
+ case "libs":
+ state[0].data = action.payload[1];
+ break;
+ case "resumeVideo":
+ state[1].data = action.payload[1];
+ break;
+ case "resumeAudio":
+ state[2].data = action.payload[1];
+ break;
+ case "nextup":
+ state[3].data = action.payload[1];
+ break;
+ default:
+ break;
+ }
+ },
+ addLatestMedia: (state, action) => {
+ state.push(action.payload);
+ },
+ },
+});
+
+export const { setData, addLatestMedia } = homePageSlice.actions;
+export default homePageSlice.reducer;