More updates #26

This commit is contained in:
prayag17 committed 2023-04-21 17:38:36 +05:30
1 parent 0035488770
commit fa3b2c7e6b
12 files changed
+146 -64

No files matched your search

+8 -5
View File
@@ -61,10 +61,11 @@ import { Jellyfin } from "@jellyfin/sdk";
import { version as appVer } from "../package.json";
import { v4 as uuidv4 } from "uuid";
import { delServer, getServer } from "./utils/storage/servers.js";
import { getUser } from "./utils/storage/user.js";
import { delUser, getUser } from "./utils/storage/user.js";
import { useDispatch } from "react-redux";
import { showSidemenu } from "./utils/slice/sidemenu.js";
import FavouritePage from "./routes/favourite/root.jsx";
const jellyfin = new Jellyfin({
clientInfo: {
name: "JellyPlayer",
@@ -77,10 +78,7 @@ const jellyfin = new Jellyfin({
});
event.on("create-jellyfin-api", (serverAddress) => {
window.api = jellyfin.createApi(
serverAddress,
sessionStorage.getItem("accessToken"),
);
window.api = jellyfin.createApi(serverAddress);
// window.api = jellyfin.createApi(serverAddress);
});
event.on("set-api-accessToken", (serverAddress) => {
@@ -262,6 +260,7 @@ function App() {
const handleRemoveServer = async () => {
await delServer();
await delUser();
let result = await relaunch();
console.log(result);
};
@@ -389,6 +388,10 @@ function App() {
path="/item/:id"
element={<ItemDetail />}
/>
<Route
path="/favourite"
element={<FavouritePage />}
/>
{/* Logical Routes */}
+2 -1
View File
@@ -134,7 +134,7 @@ export const Card = ({
>
<CardActionArea
sx={{ p: "1px" }}
component="div"
component={Box}
onClick={
!!onClickEvent
? onClickEvent
@@ -142,6 +142,7 @@ export const Card = ({
navigate(`/item/${itemId}`);
}
}
className="cardBox"
>
<Box
className="card-media-container"
+3 -2
View File
@@ -24,8 +24,9 @@
transition: opacity $transition-time-default;
}
}
&:hover .card-media-overlay,
&:focus .card-media-overlay {
&Box:hover .card-media-overlay,
&Box:focus-within .card-media-overlay,
&Box:focus .card-media-overlay {
opacity: 1;
}
&-image {
+17 -2
View File
@@ -2,7 +2,8 @@
import React, { useState } from "react";
import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom";
import { useNavigate, Link } from "react-router-dom";
// import Link from "@mui/material/Link";
import Divider from "@mui/material/Divider";
import Stack from "@mui/material/Stack";
@@ -52,6 +53,7 @@ export const EpisodeCard = ({
showName,
episodeLocation,
centerAlignText = false,
parentId,
}) => {
const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true);
@@ -111,6 +113,7 @@ export const EpisodeCard = ({
navigate(`/item/${itemId}`);
}
}
className="cardBox"
>
<Box
className="card-media-container"
@@ -249,8 +252,19 @@ export const EpisodeCard = ({
noWrap
width="fit-content"
maxWidth="100%"
onClick={(e) => {
e.stopPropagation();
navigate(`/item/${parentId}`);
}}
sx={{
"&:hover": {
textDecoration: "underline",
},
}}
>
{`${showName} - ${episodeLocation}`}
{showName}
{" - "}
{episodeLocation}
</Typography>
</>
)}
@@ -402,4 +416,5 @@ EpisodeCard.propTypes = {
itemTicks: PropTypes.number,
itemRating: PropTypes.number,
centerAlignText: PropTypes.bool,
parentId: PropTypes.any,
};
+1 -1
View File
@@ -52,7 +52,7 @@ export const CardScroller = ({
return (
<Box className="card-scroller-container" sx={{ mb: 4 }}>
<Box
sx={{ mb: 2 }}
sx={{ mb: 1 }}
className={
disableDecoration
? `card-scroller-header-container hidden-decoration`
@@ -32,6 +32,6 @@
.hidden-decoration {
.card-scroller-heading-decoration {
display: hidden;
display: none;
}
}
+15 -26
View File
@@ -91,7 +91,8 @@ export const SideMenu = ({}) => {
console.log("Logging out user...");
await window.api.logout();
delUser();
dispatch(hideSidemenu());
sessionStorage.removeItem("accessToken");
event.emit("create-jellyfin-api", window.api.basePath);
navigate("/login");
};
@@ -231,38 +232,26 @@ export const SideMenu = ({}) => {
className="sidemenu-item-container"
disablePadding
>
<NavLink
<ListItemButton
component={NavLink}
to="/home"
className={({
isActive,
isPending,
}) =>
isPending
? "sidemenu-item-pending sidemenu-item"
: isActive
? "sidemenu-item-active sidemenu-item"
: "sidemenu-item"
}
className="sidemenu-item"
sx={{
minHeight: 48,
justifyContent: "center",
px: 2.5,
}}
>
<ListItemButton
<ListItemIcon
sx={{
minHeight: 48,
minWidth: 0,
justifyContent:
"center",
px: 2.5,
}}
>
<ListItemIcon
sx={{
minWidth: 0,
justifyContent:
"center",
}}
>
<MdiHomeVariantOutline></MdiHomeVariantOutline>
</ListItemIcon>
</ListItemButton>
</NavLink>
<MdiHomeVariantOutline></MdiHomeVariantOutline>
</ListItemIcon>
</ListItemButton>
</ListItem>
</Tooltip>
<Tooltip
+7
View File
@@ -0,0 +1,7 @@
/** @format */
const FavouritePage = () => {
return <></>;
};
export default FavouritePage;
+2
View File
@@ -167,6 +167,8 @@ const Home = () => {
console.log("Logging out user...");
await window.api.logout();
delUser();
sessionStorage.removeItem("accessToken");
event.emit("create-jellyfin-api", window.api.basePath);
navigate("/login");
};
+75 -23
View File
@@ -14,6 +14,7 @@ import Tab from "@mui/material/Tab";
import Grid2 from "@mui/material/Unstable_Grid2";
import Button from "@mui/material/Button";
import IconButton from "@mui/material/IconButton";
// import Chip from "@mui/material/Chip";
import { green, pink } from "@mui/material/colors";
import { Blurhash } from "react-blurhash";
@@ -56,6 +57,7 @@ function TabPanel(props) {
id={`full-width-tabpanel-${index}`}
aria-labelledby={`full-width-tab-${index}`}
{...other}
style={{ marginTop: "1em" }}
>
{value === index && <Box>{children}</Box>}
</div>
@@ -198,24 +200,8 @@ const ItemDetail = () => {
refetchOnWindowFocus: true,
});
const personShows = useQuery({
queryKey: ["item", "personShows"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
personIds: [id],
includeItemTypes: [BaseItemKind.Series],
recursive: true,
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
sortOrder: ["Descending"],
});
return result.data;
},
enabled: item.isSuccess && item.data.Type == "Person",
networkMode: "always",
});
const personMovies = useQuery({
queryKey: ["item", "personMovies"],
queryKey: ["item", id, "personMovies"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
@@ -230,8 +216,25 @@ const ItemDetail = () => {
enabled: item.isSuccess && item.data.Type == "Person",
networkMode: "always",
});
const personShows = useQuery({
queryKey: ["item", id, "personShows"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
personIds: [id],
includeItemTypes: [BaseItemKind.Series],
recursive: true,
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
sortOrder: ["Descending"],
});
return result.data;
},
enabled: item.isSuccess && item.data.Type == "Person",
networkMode: "always",
});
const personBooks = useQuery({
queryKey: ["item", "personBooks"],
queryKey: ["item", id, "personBooks"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
@@ -247,7 +250,7 @@ const ItemDetail = () => {
networkMode: "always",
});
const personPhotos = useQuery({
queryKey: ["item", "personPhotos"],
queryKey: ["item", id, "personPhotos"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
@@ -262,7 +265,7 @@ const ItemDetail = () => {
networkMode: "always",
});
const personEpisodes = useQuery({
queryKey: ["item", "personEpisodes"],
queryKey: ["item", id, "personEpisodes"],
queryFn: async () => {
const result = await getItemsApi(window.api).getItems({
userId: user.data.Id,
@@ -314,6 +317,34 @@ const ItemDetail = () => {
const personTabs = ["Movies", "TV Shows", "Books", "Photos", "Episodes"];
useEffect(() => {
if (
personMovies.isSuccess &&
personShows.isSuccess &&
personBooks.isSuccess &&
personPhotos.isSuccess &&
personEpisodes.isSuccess
) {
if (personMovies.data.Items.length != 0) {
setActivePersonTab(0);
} else if (personShows.data.Items.length != 0) {
setActivePersonTab(1);
} else if (personBooks.data.Items.length != 0) {
setActivePersonTab(2);
} else if (personPhotos.data.Items.length != 0) {
setActivePersonTab(3);
} else if (personEpisodes.data.Items.length != 0) {
setActivePersonTab(4);
}
}
}, [
personMovies.isLoading,
personShows.isLoading,
personBooks.isLoading,
personPhotos.isLoading,
personEpisodes.isLoading,
]);
if (item.isLoading || similarItems.isLoading) {
return (
<Box
@@ -362,7 +393,6 @@ const ItemDetail = () => {
pb: 3,
position: "relative",
flexFlow: "column",
gap: 1,
}}
>
<Box className="item-detail-header" mb={0}>
@@ -434,6 +464,19 @@ const ItemDetail = () => {
: {}
}
>
<Chip
className="card-indicator"
label={<MdiCheck />}
sx={{
transition: "opacity 150ms",
opacity: item.data.UserData
.Played
? 1
: 0,
top: 5,
right: 5,
}}
/>
{!!item.data.ImageTags.Primary && (
<img
src={
@@ -691,7 +734,10 @@ const ItemDetail = () => {
</Box>
</Box>
{item.data.Genres != 0 && (
<Box className="item-media-container">
<Box
className="item-media-container"
sx={{ mb: 2 }}
>
<Stack
direction="row"
gap={1}
@@ -800,7 +846,7 @@ const ItemDetail = () => {
)}
{seasons.isSuccess && (
<Box>
<Box sx={{ mb: 2 }}>
<Tabs
variant="scrollable"
scrollButtons="auto"
@@ -809,6 +855,7 @@ const ItemDetail = () => {
setCurrentSeason(newVal);
}}
sx={{ mb: 2 }}
selectionFollowsFocus
>
{seasons.data.Items.map(
(season, index) => {
@@ -939,6 +986,7 @@ const ItemDetail = () => {
}}
displayCards={8}
title="Cast"
disableDecoration
>
{item.data.People.map((person, index) => {
return (
@@ -1594,6 +1642,9 @@ const ItemDetail = () => {
mitem.SeriesName
}
episodeLocation={`S${mitem.ParentIndexNumber}:E${mitem.IndexNumber}`}
parentId={
mitem.SeriesId
}
/>
</Grid2>
);
@@ -1615,6 +1666,7 @@ const ItemDetail = () => {
}}
displayCards={8}
title={`More Like This`}
disableDecoration
>
{similarItems.data.Items.map(
(simItem, index) => {
+1 -2
View File
@@ -362,7 +362,7 @@ export const UserLoginManual = () => {
).getBrandingOptions();
return result.data;
},
enabled: !window.api,
enabled: !!window.api,
networkMode: "always",
});
@@ -410,7 +410,6 @@ export const UserLoginManual = () => {
event.emit("set-api-accessToken", window.api.basePath);
// setAccessToken(user.data.AccessToken)
setLoading(false);
dispatch(showSidemenu());
navigate(`/home`);
};
+14 -1
View File
@@ -216,7 +216,20 @@ export const ServerSetup = (props) => {
variant="outlined"
// inputRef={serverIp}
onChange={(event) => {
setServerIp(event.target.value);
if (
event.target.value.charAt(
event.target.value.length - 1,
) == "/"
) {
setServerIp(
event.target.value.slice(
0,
-1,
),
);
} else {
setServerIp(event.target.value);
}
}}
helperText="Add your server adddress with https:// or http://"
></TextField>