Display songs in libView and update titlePage #9 #26

This commit is contained in:
prayag17 committed 2023-04-24 14:49:05 +05:30
1 parent ed1633fb21
commit 53f042a453
10 files changed
+391 -103

No files matched your search

-11
View File
@@ -137,13 +137,8 @@ function App() {
const server = await getServer(); const server = await getServer();
if (server == null) { if (server == null) {
console.log("server not found");
return false; return false;
} else { } else {
// if (!window.api) {
// console.log("Creating Jf api (without accessToken)");
// event.emit("create-jellyfin-api", server.Ip);
// }
return true; return true;
} }
}; };
@@ -159,7 +154,6 @@ function App() {
const userSaved = async () => { const userSaved = async () => {
const user = await getUser(); const user = await getUser();
console.log("User store => ", user);
if (user == null) { if (user == null) {
return false; return false;
} else { } else {
@@ -189,7 +183,6 @@ function App() {
}) })
.catch((error) => { .catch((error) => {
setServerReachable(false); setServerReachable(false);
console.error(error);
setChecking(false); setChecking(false);
}); });
}; };
@@ -253,22 +246,18 @@ function App() {
const handleRelaunch = async () => { const handleRelaunch = async () => {
let result = await relaunch(); let result = await relaunch();
console.log(result);
}; };
const handleRemoveServer = async () => { const handleRemoveServer = async () => {
await delServer(); await delServer();
await delUser(); await delUser();
let result = await relaunch(); let result = await relaunch();
console.log(result);
}; };
const location = useLocation(); const location = useLocation();
if (!window.api) { if (!window.api) {
console.log("WindowAPi not present");
serverAvailable().then((available) => { serverAvailable().then((available) => {
if (available) { if (available) {
console.log(available);
createApi().then( createApi().then(
userSaved().then((userSavedBool) => { userSaved().then((userSavedBool) => {
if (userSavedBool) { if (userSavedBool) {
+8 -8
View File
@@ -51,7 +51,7 @@ export const Card = ({
const navigate = useNavigate(); const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true); const [imgLoading, setImgLoading] = useState(true);
const [isWatched, setIsWatched] = useState(watchedStatus); const [isWatched, setIsWatched] = useState(watchedStatus);
const [isFavourite, setIsFavourite] = useState(favourite); const [isFavorite, setisFavorite] = useState(favourite);
const [watchedCountState, setWatchedCountState] = useState(watchedCount); const [watchedCountState, setWatchedCountState] = useState(watchedCount);
const handleMarkAsPlayOrUnMarkAsPlay = async () => { const handleMarkAsPlayOrUnMarkAsPlay = async () => {
let result; let result;
@@ -71,18 +71,18 @@ export const Card = ({
}; };
const handleLiking = async () => { const handleLiking = async () => {
let result; let result;
if (isFavourite) { if (isFavorite) {
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({ result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
userId: currentUser.Id, userId: currentUser.Id,
itemId: itemId, itemId: itemId,
}); });
} else if (!isFavourite) { } else if (!isFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({ result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: currentUser.Id, userId: currentUser.Id,
itemId: itemId, itemId: itemId,
}); });
} }
setIsFavourite(result.data.IsFavorite); setisFavorite(result.data.IsFavorite);
}; };
const availableMarkButtonTypes = [ const availableMarkButtonTypes = [
@@ -214,7 +214,7 @@ export const Card = ({
window.api.basePath + window.api.basePath +
"/Items/" + "/Items/" +
itemId + itemId +
"/Images/Primary" "/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
} }
alt={itemName} alt={itemName}
sx={{ sx={{
@@ -240,8 +240,8 @@ export const Card = ({
hash={blurhash} hash={blurhash}
width="100%" width="100%"
height="100%" height="100%"
resolutionX={64} resolutionX={24}
resolutionY={64} resolutionY={24}
style={{ style={{
aspectRatio: aspectRatio:
cardOrientation == "landscape" cardOrientation == "landscape"
@@ -311,7 +311,7 @@ export const Card = ({
handleLiking(); handleLiking();
}} }}
> >
{isFavourite ? ( {isFavorite ? (
<MdiHeart <MdiHeart
sx={{ color: pink[700] }} sx={{ color: pink[700] }}
/> />
+4 -11
View File
@@ -56,7 +56,6 @@ export const EpisodeCard = ({
parentId, parentId,
}) => { }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const [imgLoading, setImgLoading] = useState(true);
const [isWatched, setIsWatched] = useState(watchedStatus); const [isWatched, setIsWatched] = useState(watchedStatus);
const [isFavourite, setIsFavourite] = useState(favourite); const [isFavourite, setIsFavourite] = useState(favourite);
const handleMarkAsPlayOrUnMarkAsPlay = async () => { const handleMarkAsPlayOrUnMarkAsPlay = async () => {
@@ -72,7 +71,6 @@ export const EpisodeCard = ({
itemId: itemId, itemId: itemId,
}); });
} }
console.log(result.data);
setIsWatched(result.data.Played); setIsWatched(result.data.Played);
}; };
const handleLiking = async () => { const handleLiking = async () => {
@@ -88,7 +86,6 @@ export const EpisodeCard = ({
itemId: itemId, itemId: itemId,
}); });
} }
console.log(result.data.IsFavorite);
setIsFavourite(result.data.IsFavorite); setIsFavourite(result.data.IsFavorite);
}; };
@@ -132,13 +129,10 @@ export const EpisodeCard = ({
opacity: isWatched ? 1 : 0, opacity: isWatched ? 1 : 0,
}} }}
/> />
<Box <Box className="card-media-image-container">
className="card-media-image-container"
sx={{ opacity: imgLoading ? 0 : 1 }}
>
{imageTags && ( {imageTags && (
<CardMedia <CardMedia
component="img" component="div"
image={ image={
window.api.basePath + window.api.basePath +
"/Items/" + "/Items/" +
@@ -153,7 +147,6 @@ export const EpisodeCard = ({
borderRadiusDefault, borderRadiusDefault,
overflow: "hidden", overflow: "hidden",
}} }}
onLoad={() => setImgLoading(false)}
className="card-image" className="card-image"
></CardMedia> ></CardMedia>
)} )}
@@ -163,8 +156,8 @@ export const EpisodeCard = ({
hash={blurhash} hash={blurhash}
width="100%" width="100%"
height="100%" height="100%"
resolutionX={512} resolutionX={12}
resolutionY={910} resolutionY={18}
style={{ style={{
aspectRatio: "1.777", aspectRatio: "1.777",
}} }}
-1
View File
@@ -101,7 +101,6 @@ export const SideMenu = ({}) => {
}; };
useEffect(() => { useEffect(() => {
console.log(location.pathname.includes("login"));
if ( if (
location.pathname.includes("login") || location.pathname.includes("login") ||
location.pathname.includes("setup") location.pathname.includes("setup")
+2 -3
View File
@@ -253,7 +253,6 @@ const Home = () => {
// <></> // <></>
latestMedia.data != null && latestMedia.data != null &&
latestMedia.data.map((item, index) => { latestMedia.data.map((item, index) => {
// console.log(item);
return ( return (
<Paper <Paper
className="hero-carousel-slide" className="hero-carousel-slide"
@@ -281,10 +280,10 @@ const Home = () => {
width="1080" width="1080"
height="720" height="720"
resolutionX={ resolutionX={
720 64
} }
resolutionY={ resolutionY={
1080 96
} }
className="hero-carousel-background-blurhash" className="hero-carousel-background-blurhash"
/> />
+191 -43
View File
@@ -21,6 +21,8 @@ import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow"; import TableRow from "@mui/material/TableRow";
import TableBody from "@mui/material/TableBody"; import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell"; import TableCell from "@mui/material/TableCell";
import TextField from "@mui/material/TextField";
import MenuItem from "@mui/material/MenuItem";
import { green, pink } from "@mui/material/colors"; import { green, pink } from "@mui/material/colors";
import { AvatarImage } from "../../components/avatar/avatar"; import { AvatarImage } from "../../components/avatar/avatar";
@@ -37,6 +39,7 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api"; import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
import { getVideosApi } from "@jellyfin/sdk/lib/utils/api/videos-api";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
@@ -303,6 +306,18 @@ const ItemDetail = () => {
networkMode: "always", networkMode: "always",
}); });
// const videoStreams = useQuery({
// queryKey: ["item", id, "videoTracks"],
// queryFn: async () => {
// const result = await getVideosApi(window.api).getVideoStream({
// itemId: item.data.Id,
// });
// return result.data;
// },
// enabled: item.isSuccess,
// networkMode: "always",
// });
const handleMarkPlayedOrunPlayed = async () => { const handleMarkPlayedOrunPlayed = async () => {
let result; let result;
if (!item.data.UserData.Played) { if (!item.data.UserData.Played) {
@@ -325,7 +340,6 @@ const ItemDetail = () => {
userId: user.data.Id, userId: user.data.Id,
itemId: item.data.Id, itemId: item.data.Id,
}); });
console.log(result.statusText);
} else if (!item.data.UserData.IsFavorite) { } else if (!item.data.UserData.IsFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({ result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id, userId: user.data.Id,
@@ -341,7 +355,6 @@ const ItemDetail = () => {
userId: user.data.Id, userId: user.data.Id,
itemId: track.Id, itemId: track.Id,
}); });
console.log(result.statusText);
} else if (!track.UserData.IsFavorite) { } else if (!track.UserData.IsFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({ result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id, userId: user.data.Id,
@@ -412,8 +425,8 @@ const ItemDetail = () => {
} }
width="100%" width="100%"
height="100%" height="100%"
resolutionX={64} resolutionX={14}
resolutionY={96} resolutionY={22}
style={{ style={{
aspectRatio: "0.666", aspectRatio: "0.666",
}} }}
@@ -436,25 +449,50 @@ const ItemDetail = () => {
> >
<Box className="item-detail-header" mb={0}> <Box className="item-detail-header" mb={0}>
<Box className="item-detail-header-backdrop"> <Box className="item-detail-header-backdrop">
{item.data.BackdropImageTags.length != 0 && ( {item.data.Type != BaseItemKind.MusicAlbum
<img ? item.data.BackdropImageTags.length !=
src={ 0 && (
window.api.basePath + <img
"/Items/" + src={
item.data.Id + item.data.Type ==
"/Images/Backdrop" BaseItemKind.MusicAlbum
} ? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
style={{ : `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
opacity: backdropImageLoaded }
? 1 style={{
: 0, opacity: backdropImageLoaded
}} ? 1
className="item-detail-image" : 0,
onLoad={() => }}
setBackdropImageLoaded(true) className="item-detail-image"
} onLoad={() =>
/> setBackdropImageLoaded(
)} true,
)
}
/>
)
: !!item.data.ParentBackdropItemId && (
<img
src={
item.data.Type ==
BaseItemKind.MusicAlbum
? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`
}
style={{
opacity: backdropImageLoaded
? 1
: 0,
}}
className="item-detail-image"
onLoad={() =>
setBackdropImageLoaded(
true,
)
}
/>
)}
{item.data.BackdropImageTags.length != 0 && ( {item.data.BackdropImageTags.length != 0 && (
<Blurhash <Blurhash
hash={ hash={
@@ -466,8 +504,8 @@ const ItemDetail = () => {
} }
width="100%" width="100%"
height="100%" height="100%"
resolutionX={64} resolutionX={12}
resolutionY={96} resolutionY={18}
style={{ style={{
aspectRatio: "0.666", aspectRatio: "0.666",
}} }}
@@ -522,7 +560,7 @@ const ItemDetail = () => {
window.api.basePath + window.api.basePath +
"/Items/" + "/Items/" +
item.data.Id + item.data.Id +
"/Images/Primary?quality=10" "/Images/Primary?fillHeight=532&fillWidth=300&quality=96"
} }
style={{ style={{
opacity: primageImageLoaded opacity: primageImageLoaded
@@ -549,8 +587,8 @@ const ItemDetail = () => {
} }
width="100%" width="100%"
height="100%" height="100%"
resolutionX={64} resolutionX={12}
resolutionY={96} resolutionY={8}
style={{ style={{
aspectRatio: 0.666, aspectRatio: 0.666,
}} }}
@@ -773,7 +811,7 @@ const ItemDetail = () => {
</Box> </Box>
</Box> </Box>
{item.data.Genres != 0 && ( {item.data.Genres != 0 && (
<Box sx={{ mb: 2 }}> <Box sx={{ mb: 2, width: "50%" }}>
<Stack <Stack
direction="row" direction="row"
gap={1} gap={1}
@@ -815,19 +853,134 @@ const ItemDetail = () => {
> >
Artists Artists
</Typography> </Typography>
{item.data.Artists.map((mitem, mindex) => { <Stack
return ( direction="row"
<Typography gap={0.5}
key={mindex} divider={
variant="h6" <Typography variant="h6">
> ,
{mitem}
</Typography> </Typography>
); }
})} >
{item.data.Artists.map(
(mitem, mindex) => {
return (
<Typography
key={mindex}
variant="h6"
>
{mitem}
</Typography>
);
},
)}
</Stack>
</Stack> </Stack>
)} )}
{!!item.data.MediaStreams &&
item.data.MediaStreams.length != 0 && (
<>
<Box sx={{ mb: 2, width: "50%" }}>
<Stack
direction="row"
gap={1}
alignItems="center"
>
<Typography
className="item-detail-heading"
variant="h5"
mr={2}
>
Video
</Typography>
<TextField
defaultValue={
item.data
.MediaStreams[0]
.DisplayTitle
}
select
fullWidth
hiddenLabel
>
{item.data.MediaStreams.map(
(
stream,
sindex,
) => {
if (
stream.Type ==
BaseItemKind.Video
)
return (
<MenuItem
key={
sindex
}
value={
stream.DisplayTitle
}
>
{
stream.DisplayTitle
}
</MenuItem>
);
},
)}
</TextField>
</Stack>
</Box>
<Box sx={{ mb: 2, width: "50%" }}>
<Stack
direction="row"
gap={1}
alignItems="center"
>
<Typography
className="item-detail-heading"
variant="h5"
mr={2}
>
Audio
</Typography>
<TextField
select
fullWidth
hiddenLabel
>
{item.data.MediaStreams.map(
(
stream,
sindex,
) => {
if (
stream.Type ==
BaseItemKind.Audio
)
return (
<MenuItem
key={
sindex
}
value={
stream.DisplayTitle
}
>
{
stream.DisplayTitle
}
</MenuItem>
);
},
)}
</TextField>
</Stack>
</Box>
</>
)}
{!!item.data.Overview && ( {!!item.data.Overview && (
<Box mt={3}> <Box mt={3}>
<Typography variant="h5" mb={1}> <Typography variant="h5" mb={1}>
@@ -1558,11 +1711,6 @@ const ItemDetail = () => {
.UserData .UserData
.Played .Played
} }
watchedCount={
mitem
.UserData
.PlayCount
}
blurhash={ blurhash={
mitem.ImageBlurHashes == mitem.ImageBlurHashes ==
{} {}
+4 -3
View File
@@ -39,10 +39,11 @@
} }
} }
&-image { &-image {
position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
position: absolute; object-position: top;
transition: opacity $transition-time-default; transition: opacity $transition-time-default;
&-blurhash { &-blurhash {
z-index: -1; z-index: -1;
@@ -71,8 +72,8 @@
} }
&-title-logo { &-title-logo {
filter: drop-shadow(0 0 10px rgb(0 0 0 /0.2)); filter: drop-shadow(0 0 10px rgb(0 0 0 /0.2));
max-width: 75%; height: 100%;
height: 2em; width: 45%;
object-fit: contain; object-fit: contain;
object-position: bottom; object-position: bottom;
} }
+134 -21
View File
@@ -24,10 +24,17 @@ import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails"; import AccordionDetails from "@mui/material/AccordionDetails";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper";
import Table from "@mui/material/Table";
import TableContainer from "@mui/material/TableContainer";
import TableRow from "@mui/material/TableRow";
import TableCell from "@mui/material/TableCell";
import IconButton from "@mui/material/IconButton";
import { theme } from "../../theme"; import { theme } from "../../theme";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api"; import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api"; import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api";
@@ -45,6 +52,16 @@ import { MdiFilterOutline } from "../../components/icons/mdiFilterOutline";
import { clrBackgroundDarkOpacity0_8 } from "../../palette.module.scss"; import { clrBackgroundDarkOpacity0_8 } from "../../palette.module.scss";
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
import {
BaseItemKind,
CollectionTypeOptions,
} from "@jellyfin/sdk/lib/generated-client";
import { getRuntimeMusic } from "../../utils/date/time";
import "./library.module.scss";
import { MdiMusic } from "../../components/icons/mdiMusic";
import { MdiHeart } from "../../components/icons/mdiHeart";
import { MdiHeartOutline } from "../../components/icons/mdiHeartOutline";
const LibraryView = () => { const LibraryView = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@@ -64,12 +81,17 @@ const LibraryView = () => {
}, },
}); });
const [sortAscending, setSortAscending] = useState(false); const [sortAscending, setSortAscending] = useState(true);
const [sortBy, setSortBy] = useState("SortName"); const [sortBy, setSortBy] = useState("SortName");
const [sortByData, setSortByData] = useState([ const [sortByData, setSortByData] = useState([
{ title: "Name", value: "SortName" }, { title: "Name", value: "SortName" },
{ title: "Critic Rating", value: "CriticRating" },
{ title: "Rating", value: "CommunityRating" }, { title: "Rating", value: "CommunityRating" },
{ title: "Release Date", value: "PremiereDate" }, { title: "Release Date", value: "PremiereDate" },
{ title: "Date Added", value: "DateCreated" },
{ title: "Play Count", value: "PlayCount" },
{ title: "Runtime", value: "Runtime" },
{ title: "Random", value: "Random" },
]); ]);
const handleSortChange = (e) => { const handleSortChange = (e) => {
setSortAscending(e.target.checked); setSortAscending(e.target.checked);
@@ -98,7 +120,7 @@ const LibraryView = () => {
const [isPlayed, setIsPlayed] = useState(false); const [isPlayed, setIsPlayed] = useState(false);
const [isUnPlayed, setIsUnPlayed] = useState(false); const [isUnPlayed, setIsUnPlayed] = useState(false);
const [isResumable, setIsResumable] = useState(false); const [isResumable, setIsResumable] = useState(false);
const [isFavourite, setIsFavourite] = useState(false); const [isFavorite, setisFavorite] = useState(false);
const [isLiked, setIsLiked] = useState(false); const [isLiked, setIsLiked] = useState(false);
const [isUnliked, setIsUnliked] = useState(false); const [isUnliked, setIsUnliked] = useState(false);
const availableWatchStatus = [ const availableWatchStatus = [
@@ -120,7 +142,7 @@ const LibraryView = () => {
{ {
title: "Favourite", title: "Favourite",
value: false, value: false,
state: (val) => setIsFavourite(val), state: (val) => setisFavorite(val),
}, },
{ {
title: "Liked", title: "Liked",
@@ -186,26 +208,27 @@ const LibraryView = () => {
if (currentLib.isSuccess) { if (currentLib.isSuccess) {
if (currentLib.data.Items[0].CollectionType == "movies") { if (currentLib.data.Items[0].CollectionType == "movies") {
setViewType([ setViewType([
{ title: "Movies", value: "Movie" }, { title: "Movies", value: BaseItemKind.Movie },
{ title: "Collections", value: "BoxSet" }, { title: "Collections", value: BaseItemKind.BoxSet },
{ title: "Actors", value: "Person" }, { title: "Actors", value: BaseItemKind.Person },
{ title: "Genres", value: "Genre" }, { title: "Genres", value: BaseItemKind.Genre },
{ title: "Studios", value: "Studio" }, { title: "Studios", value: BaseItemKind.Studio },
]); ]);
} else if (currentLib.data.Items[0].CollectionType == "music") { } else if (currentLib.data.Items[0].CollectionType == "music") {
setViewType([ setViewType([
{ title: "Albums", value: "MusicAlbum" }, { title: "Songs", value: BaseItemKind.Audio },
{ title: "Artists", value: "MusicArtist" }, { title: "Albums", value: BaseItemKind.MusicAlbum },
{ title: "Genres", value: "MusicGenre" }, { title: "Artists", value: BaseItemKind.MusicArtist },
{ title: "Genres", value: BaseItemKind.MusicGenre },
]); ]);
} else if ( } else if (
currentLib.data.Items[0].CollectionType == "tvshows" currentLib.data.Items[0].CollectionType == "tvshows"
) { ) {
setViewType([ setViewType([
{ title: "Series", value: "Series" }, { title: "Series", value: BaseItemKind.Series },
{ title: "Actors", value: "Person" }, { title: "Actors", value: BaseItemKind.Person },
{ title: "Genres", value: "Genre" }, { title: "Genres", value: BaseItemKind.Genre },
{ title: "Networks", value: "Studio" }, { title: "Networks", value: BaseItemKind.Studio },
]); ]);
} else { } else {
setViewType([]); setViewType([]);
@@ -260,7 +283,7 @@ const LibraryView = () => {
isPlayed && "IsPlayed", isPlayed && "IsPlayed",
isUnPlayed && "IsUnplayed", isUnPlayed && "IsUnplayed",
isResumable && "IsResumable", isResumable && "IsResumable",
isFavourite && "IsFavorite", isFavorite && "IsFavorite",
isLiked && "IsFavoriteOrLikes", isLiked && "IsFavoriteOrLikes",
isUnliked && "Dislikes", isUnliked && "Dislikes",
], ],
@@ -291,7 +314,7 @@ const LibraryView = () => {
isPlayed, isPlayed,
isUnPlayed, isUnPlayed,
isResumable, isResumable,
isFavourite, isFavorite,
isLiked, isLiked,
isUnliked, isUnliked,
], ],
@@ -343,6 +366,22 @@ const LibraryView = () => {
threshold: 1, threshold: 1,
}); });
const handleLiking = async (item) => {
let result;
if (item.UserData.isFavorite) {
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
userId: user.data.Id,
itemId: item.Id,
});
} else if (!item.UserData.isFavorite) {
result = await getUserLibraryApi(window.api).markFavoriteItem({
userId: user.data.Id,
itemId: item.Id,
});
}
items.refetch();
};
return ( return (
<Box <Box
sx={{ sx={{
@@ -708,12 +747,12 @@ const LibraryView = () => {
checkedIcon={ checkedIcon={
<MdiSortAscending /> <MdiSortAscending />
} }
color="white"
onChange={handleSortChange}
defaultValue={sortAscending}
sx={{ sx={{
color: "white !important", color: "white !important",
}} }}
color="white"
onChange={handleSortChange}
defaultValue={sortAscending}
/> />
<TextField <TextField
select select
@@ -771,7 +810,7 @@ const LibraryView = () => {
{items.isSuccess && {items.isSuccess &&
(items.data.TotalRecordCount == 0 ? ( (items.data.TotalRecordCount == 0 ? (
<EmptyNotice /> <EmptyNotice />
) : ( ) : currentViewType != BaseItemKind.Audio ? (
<Grid2 <Grid2
container container
columns={{ xs: 2, sm: 4, md: 8 }} columns={{ xs: 2, sm: 4, md: 8 }}
@@ -850,6 +889,80 @@ const LibraryView = () => {
); );
})} })}
</Grid2> </Grid2>
) : (
<TableContainer>
<Table>
{items.data.Items.map((item, index) => {
return (
<TableRow
key={index}
sx={{
"& td,& th": {
borderBottom:
"1px solid rgb(255 255 255 / 0.1)",
},
"&:hover": {
background:
"rgb(255 255 255 / 0.05)",
},
}}
>
<TableCell width="4.5em">
<Box className="library-list-image-container">
{!!item
.ImageTags
.Primary && (
<img
className="library-list-image"
src={`${window.api.basePath}/Items/${item.Id}/Images/Primary?quality=80&tag=${item.ImageTags.Primary}`}
/>
)}
<Box className="library-list-icon-container">
<MdiMusic className="library-list-icon" />
</Box>
</Box>
</TableCell>
<TableCell>
<Typography variant="h6">
{item.Name}
</Typography>
<Typography
variant="subtitle1"
sx={{
opacity: 0.7,
}}
>
{item.Album}
</Typography>
</TableCell>
<TableCell>
<Typography variant="subtitle1">
{getRuntimeMusic(
item.RunTimeTicks,
)}
</Typography>
</TableCell>
<TableCell width="1em">
<IconButton
onClick={() => {
handleLiking(
item,
);
}}
>
{item.UserData
.IsFavorite ? (
<MdiHeart />
) : (
<MdiHeartOutline />
)}
</IconButton>
</TableCell>
</TableRow>
);
})}
</Table>
</TableContainer>
))} ))}
{items.isError && <ErrorNotice />} {items.isError && <ErrorNotice />}
</Box> </Box>
+36
View File
@@ -0,0 +1,36 @@
/** @format */
.library-list {
&-image {
position: relative;
width: 100%;
height: 100%;
z-index: 1;
object-fit: cover;
&-container {
position: relative;
width: 4.5em;
height: 4.5em;
aspect-ratio: 1;
border-radius: $border-radius-intensity-1;
overflow: hidden;
box-shadow: 0 2px 7px rgb(0 0 0 / 0.2);
}
}
&-icon {
font-size: 3em;
fill: url(#clr-gradient-default) !important;
&-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: 0;
background: $clr-gradient-dark;
}
}
}
+12 -2
View File
@@ -40,12 +40,22 @@ export const getRuntimeMusic = (ticks) => {
let timeSec = Math.floor(time / 1000); let timeSec = Math.floor(time / 1000);
let timeMin = Math.floor(timeSec / 60); let timeMin = Math.floor(timeSec / 60);
timeSec -= timeMin * 60; timeSec -= timeMin * 60;
timeSec = timeSec == 0 ? 0o0 : timeSec;
if (timeMin > 60) { if (timeMin > 60) {
let timeHr = Math.floor(timeMin / 60); let timeHr = Math.floor(timeMin / 60);
timeMin -= timeHr * 60; timeMin -= timeHr * 60;
formatedTime = `${timeHr}:${timeMin}`; formatedTime = `${timeHr}:${timeMin.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}:${timeSec.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}`;
} else { } else {
formatedTime = `${timeMin}:${timeSec}`; formatedTime = `${timeMin}:${timeSec.toLocaleString([], {
minimumIntegerDigits: 2,
useGrouping: false,
})}`;
} }
return formatedTime; return formatedTime;
}; };