refactor: convert more files to typescript
This commit is contained in:
19 files changed
+93
-451
No files matched your search
@@ -16,11 +16,11 @@ export default function LikeButton({
|
|||||||
userId,
|
userId,
|
||||||
itemName,
|
itemName,
|
||||||
}: {
|
}: {
|
||||||
itemId: string;
|
itemId: string | undefined;
|
||||||
isFavorite: boolean;
|
isFavorite: boolean | undefined;
|
||||||
queryKey: string[];
|
queryKey: string[] | undefined;
|
||||||
userId: string;
|
userId: string | undefined;
|
||||||
itemName: string;
|
itemName: string | undefined;
|
||||||
}) {
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -29,6 +29,9 @@ export default function LikeButton({
|
|||||||
const handleLiking = async () => {
|
const handleLiking = async () => {
|
||||||
let result: UserItemDataDto = null!;
|
let result: UserItemDataDto = null!;
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
result = (
|
result = (
|
||||||
await getUserLibraryApi(api).unmarkFavoriteItem({
|
await getUserLibraryApi(api).unmarkFavoriteItem({
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ export default function MarkPlayedButton({
|
|||||||
userId,
|
userId,
|
||||||
itemName,
|
itemName,
|
||||||
}: {
|
}: {
|
||||||
itemId: string;
|
itemId?: string;
|
||||||
isPlayed: boolean;
|
isPlayed?: boolean;
|
||||||
queryKey: string[];
|
queryKey?: string[];
|
||||||
userId: string;
|
userId?: string;
|
||||||
itemName: string;
|
itemName?: string;
|
||||||
}) {
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
@@ -30,6 +30,11 @@ export default function MarkPlayedButton({
|
|||||||
const handleMarking = async () => {
|
const handleMarking = async () => {
|
||||||
let result = null;
|
let result = null;
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
|
|
||||||
if (!isPlayed) {
|
if (!isPlayed) {
|
||||||
result = await getPlaystateApi(api).markPlayedItem({
|
result = await getPlaystateApi(api).markPlayedItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ type PlayButtonProps = {
|
|||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
audio?: boolean;
|
audio?: boolean;
|
||||||
size?: "small" | "large" | "medium";
|
size?: "small" | "large" | "medium";
|
||||||
playlistItem?: BaseItemDto;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
trackIndex?: number;
|
trackIndex?: number;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
import { useApi } from "../../utils/store/api";
|
|
||||||
import "./card.scss";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {string} seriesId
|
|
||||||
* @property {boolean} hideText
|
|
||||||
* @property {() => {}} onClick
|
|
||||||
* @property {boolean} disablePadding
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const ActorCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
seriesId,
|
|
||||||
hideText,
|
|
||||||
onClick,
|
|
||||||
disablePadding,
|
|
||||||
}) => {
|
|
||||||
const [api] = useApi((state) => [state.api]);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate(`/person/${item.Id}`);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-actor"
|
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">person</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
seriesId ? item.SeriesId : item.Id,
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
quality: 80,
|
|
||||||
fillHeight: 448,
|
|
||||||
fillWidth: 448,
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: hideText ? "none" : "block" }}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.9 }}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -37,8 +37,8 @@ const CardComponent = ({
|
|||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
cardTitle: string | undefined | null;
|
cardTitle: string | undefined | null;
|
||||||
cardCaption?: string | null | number;
|
cardCaption?: string | null | number;
|
||||||
imageType: ImageType;
|
imageType?: ImageType;
|
||||||
cardType: string;
|
cardType: "square" | "thumb" | "portrait";
|
||||||
queryKey?: string[];
|
queryKey?: string[];
|
||||||
userId?: string;
|
userId?: string;
|
||||||
seriesId?: string | null;
|
seriesId?: string | null;
|
||||||
@@ -145,17 +145,13 @@ const CardComponent = ({
|
|||||||
{!disableOverlay && (
|
{!disableOverlay && (
|
||||||
<>
|
<>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
|
||||||
item={item}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack="nosub"
|
currentSubTrack="nosub"
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
className="card-play-button"
|
className="card-play-button"
|
||||||
iconProps={{
|
|
||||||
style: { fontSize: "2.5em" },
|
|
||||||
}}
|
|
||||||
iconOnly
|
iconOnly
|
||||||
audio={
|
audio={
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
@@ -168,14 +164,14 @@ const CardComponent = ({
|
|||||||
/>
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemName={item.Name}
|
itemName={item.Name ?? ""}
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemName={item.Name}
|
itemName={item.Name ?? ""}
|
||||||
isPlayed={item.UserData?.Played}
|
isPlayed={item.UserData?.Played}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
|
|
||||||
import "./card.scss";
|
|
||||||
|
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
|
||||||
import PlayButton from "../buttons/playButton";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {boolean} disableRunTime
|
|
||||||
* @property {() => {} | undefined} onClick
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const EpisodeCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
queryKey,
|
|
||||||
userId,
|
|
||||||
disableRunTime = false,
|
|
||||||
onClick,
|
|
||||||
}) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate({ to: `/episode/${item.Id}` });
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-episode"
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1.777,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!item.UserData && (
|
|
||||||
<div
|
|
||||||
className="card-indicator check"
|
|
||||||
style={{
|
|
||||||
opacity: item.UserData?.Played ? 1 : 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">done</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">tv_gen</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
|
||||||
quality: 90,
|
|
||||||
fillHeight: 512,
|
|
||||||
fillWidth: 512,
|
|
||||||
})}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="card-overlay">
|
|
||||||
<PlayButton
|
|
||||||
item={item}
|
|
||||||
userId={userId}
|
|
||||||
itemType={item.Type}
|
|
||||||
currentAudioTrack={0}
|
|
||||||
currentSubTrack={0}
|
|
||||||
currentVideoTrack={0}
|
|
||||||
className="card-play-button"
|
|
||||||
iconProps={{
|
|
||||||
style: { fontSize: "2.5em" },
|
|
||||||
}}
|
|
||||||
iconOnly
|
|
||||||
/>
|
|
||||||
<LikeButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
<MarkPlayedButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isPlayed={item.UserData?.Played}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{100 > item.UserData?.PlayedPercentage > 0 && (
|
|
||||||
<LinearProgress
|
|
||||||
variant="determinate"
|
|
||||||
value={item.UserData.PlayedPercentage}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
zIndex: 2,
|
|
||||||
height: "6px",
|
|
||||||
background: "rgb(5 5 5 / 0.5) !important",
|
|
||||||
backdropFilter: "blur(5px)",
|
|
||||||
}}
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: "block", marginTop: "0.5em" }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
gap: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
textAlign="start"
|
|
||||||
noWrap
|
|
||||||
style={{
|
|
||||||
opacity: 0.9,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
{!disableRunTime && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="start"
|
|
||||||
style={{ opacity: 0.8, flexShrink: 0 }}
|
|
||||||
>
|
|
||||||
{getRuntimeCompact(item.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
textAlign="start"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "-webkit-box",
|
|
||||||
overflow: "hidden",
|
|
||||||
WebkitBoxOrient: "vertical",
|
|
||||||
WebkitLineClamp: 3,
|
|
||||||
}}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
+22
-18
@@ -1,11 +1,8 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { type ReactNode } from "react";
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import Carousel from "react-multi-carousel";
|
import Carousel from "react-multi-carousel";
|
||||||
import "react-multi-carousel/lib/styles.css";
|
import "react-multi-carousel/lib/styles.css";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
@@ -30,14 +27,23 @@ function LeftButton(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardScroller = ({
|
type CardScrollerProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
displayCards: number;
|
||||||
|
title: string;
|
||||||
|
headingProps?: object;
|
||||||
|
disableDecoration?: boolean;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CardScroller({
|
||||||
children,
|
children,
|
||||||
displayCards,
|
displayCards,
|
||||||
title,
|
title,
|
||||||
headingProps,
|
headingProps,
|
||||||
disableDecoration = false,
|
disableDecoration = false,
|
||||||
boxProps,
|
boxProps,
|
||||||
}) => {
|
}: CardScrollerProps) {
|
||||||
const responsive = {
|
const responsive = {
|
||||||
superLargeDesktop: {
|
superLargeDesktop: {
|
||||||
// the naming can be any, depends on you.
|
// the naming can be any, depends on you.
|
||||||
@@ -73,9 +79,13 @@ export const CardScroller = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box {...boxProps} className="card-scroller-container" mb={1}>
|
<div
|
||||||
<Box
|
{...boxProps}
|
||||||
sx={{ mb: 1 }}
|
className="card-scroller-container"
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
className={
|
className={
|
||||||
disableDecoration
|
disableDecoration
|
||||||
? "card-scroller-header-container hidden-decoration"
|
? "card-scroller-header-container hidden-decoration"
|
||||||
@@ -90,7 +100,7 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
<div className="card-scroller-heading-decoration" /> {title}
|
<div className="card-scroller-heading-decoration" /> {title}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</div>
|
||||||
<Carousel
|
<Carousel
|
||||||
swipeable
|
swipeable
|
||||||
draggable
|
draggable
|
||||||
@@ -104,12 +114,6 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</Box>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
CardScroller.propTypes = {
|
|
||||||
displayCards: PropTypes.number.isRequired,
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
headingProps: PropTypes.any,
|
|
||||||
};
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
|
import type { PanInfo } from "framer-motion";
|
||||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
|
import type { MouseEvent, PointerEvent } from "react";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
|
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
import "./carousel.scss";
|
import "./carousel.scss";
|
||||||
@@ -10,12 +10,11 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import ReactMultiCarousel from "react-multi-carousel";
|
|
||||||
import Slider from "../Slider";
|
import Slider from "../Slider";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
const swipeConfidenceThreshold = 8000;
|
const swipeConfidenceThreshold = 8000;
|
||||||
const swipePower = (offset, velocity) => {
|
const swipePower = (offset: number, velocity: number) => {
|
||||||
return Math.abs(offset) * velocity;
|
return Math.abs(offset) * velocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,14 +29,11 @@ const Carousel = ({
|
|||||||
onChange,
|
onChange,
|
||||||
}: {
|
}: {
|
||||||
content: BaseItemDto[];
|
content: BaseItemDto[];
|
||||||
onChange: () => void;
|
onChange: (currentSlide: number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
|
|
||||||
const [setDirection, dir] = useCarouselStore((state) => [
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
state.setDirection,
|
|
||||||
state.direction,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
@@ -45,27 +41,6 @@ const Carousel = ({
|
|||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const responsive = {
|
|
||||||
superLargeDesktop: {
|
|
||||||
breakpoint: { max: 4000, min: 3000 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
desktop: {
|
|
||||||
breakpoint: { max: 3000, min: 1024 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
tablet: {
|
|
||||||
breakpoint: { max: 1024, min: 464 },
|
|
||||||
items: 4,
|
|
||||||
},
|
|
||||||
mobile: {
|
|
||||||
breakpoint: { max: 464, min: 0 },
|
|
||||||
items: 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Memoize the content mapping
|
// Memoize the content mapping
|
||||||
const sliderContent = useMemo(() => {
|
const sliderContent = useMemo(() => {
|
||||||
return content.map((item, index) => {
|
return content.map((item, index) => {
|
||||||
@@ -98,16 +73,23 @@ const Carousel = ({
|
|||||||
>
|
>
|
||||||
{item.ImageTags?.Thumb ? (
|
{item.ImageTags?.Thumb ? (
|
||||||
<img
|
<img
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Thumb", {
|
src={
|
||||||
tag: item.ImageTags.Primary,
|
api &&
|
||||||
fillWidth: 300,
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
})}
|
item.Id ?? "",
|
||||||
|
"Thumb",
|
||||||
|
{
|
||||||
|
tag: item.ImageTags.Primary,
|
||||||
|
fillWidth: 300,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "item-image"}
|
alt={item.Name ?? "item-image"}
|
||||||
className="carousel-indicator-image"
|
className="carousel-indicator-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="carousel-indicator-icon">
|
<div className="carousel-indicator-icon">
|
||||||
{getTypeIcon(item.Type)}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -116,7 +98,10 @@ const Carousel = ({
|
|||||||
}, [content, currentSlide, api, setDirection]);
|
}, [content, currentSlide, api, setDirection]);
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
(e, { offset, velocity }) => {
|
(
|
||||||
|
_: MouseEvent | TouchEvent | PointerEvent,
|
||||||
|
{ offset, velocity }: PanInfo,
|
||||||
|
) => {
|
||||||
const swipe = swipePower(offset.x, velocity.x);
|
const swipe = swipePower(offset.x, velocity.x);
|
||||||
if (
|
if (
|
||||||
currentSlide !== content.length - 1 &&
|
currentSlide !== content.length - 1 &&
|
||||||
@@ -147,6 +132,7 @@ const Carousel = ({
|
|||||||
drag={"x"}
|
drag={"x"}
|
||||||
dragConstraints={{ left: 0, right: 0 }}
|
dragConstraints={{ left: 0, right: 0 }}
|
||||||
dragElastic={1}
|
dragElastic={1}
|
||||||
|
//@ts-ignore
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Card } from "../../card/card";
|
import { Card } from "../../card/card";
|
||||||
import { CardScroller } from "../../cardScroller/cardScroller";
|
import CardScroller from "../../cardScroller/cardScroller";
|
||||||
import { CardsSkeleton } from "../../skeleton/cards";
|
import { CardsSkeleton } from "../../skeleton/cards";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import { useRouteContext } from "@tanstack/react-router";
|
import { useRouteContext } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Card } from "../../../card/card";
|
import { Card } from "../../../card/card";
|
||||||
import { CardScroller } from "../../../cardScroller/cardScroller";
|
import cardScroller from "../../../cardScroller/cardScroller";
|
||||||
|
|
||||||
const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -25,7 +25,11 @@ const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|||||||
if (items.isSuccess && items.data.Items.length > 0) {
|
if (items.isSuccess && items.data.Items.length > 0) {
|
||||||
return (
|
return (
|
||||||
<div className="library-genre">
|
<div className="library-genre">
|
||||||
<CardScroller title={genreName} displayCards={8} disableDecoration>
|
<cardScroller.CardScroller
|
||||||
|
title={genreName}
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
{items.data.Items.map((item) => {
|
{items.data.Items.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
@@ -42,14 +46,14 @@ const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|||||||
item.Type === BaseItemKind.Episode
|
item.Type === BaseItemKind.Episode
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
: item.Type === BaseItemKind.Series
|
: item.Type === BaseItemKind.Series
|
||||||
? `${item.ProductionYear} - ${
|
? `${item.ProductionYear} - ${
|
||||||
item.EndDate
|
item.EndDate
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
? new Date(item.EndDate).toLocaleString([], {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
})
|
})
|
||||||
: "Present"
|
: "Present"
|
||||||
}`
|
}`
|
||||||
: item.ProductionYear
|
: item.ProductionYear
|
||||||
}
|
}
|
||||||
disableOverlay={
|
disableOverlay={
|
||||||
item.Type === BaseItemKind.Person ||
|
item.Type === BaseItemKind.Person ||
|
||||||
@@ -79,7 +83,7 @@ const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</CardScroller>
|
</cardScroller.CardScroller>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import PlayButton from "@/components/buttons/playButton";
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
|
|
||||||
import heroBg from "@/assets/herobg.png";
|
import heroBg from "@/assets/herobg.png";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import "./favorite.scss";
|
import "./favorite.scss";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/favorite/")({
|
export const Route = createFileRoute("/_api/favorite/")({
|
||||||
component: FavoritePage,
|
component: FavoritePage,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Carousel from "@/components/carousel";
|
|||||||
|
|
||||||
// Custom Components
|
// Custom Components
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
||||||
import { CardsSkeleton } from "@/components/skeleton/cards";
|
import { CardsSkeleton } from "@/components/skeleton/cards";
|
||||||
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|||||||
|
|
||||||
import heroBg from "@/assets/herobg.png";
|
import heroBg from "@/assets/herobg.png";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import "./item.scss";
|
import "./item.scss";
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
|
||||||
import MusicTrack from "@/components/musicTrack";
|
import MusicTrack from "@/components/musicTrack";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./playlist.scss";
|
import "./playlist.scss";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import useDebounce from "@/utils/hooks/useDebounce";
|
|||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { EpisodeCard } from "@/components/card/episodeCard";
|
import { EpisodeCard } from "@/components/card/episodeCard";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||||
@@ -263,14 +263,14 @@ function SearchPage() {
|
|||||||
<CardScroller title="Episodes" displayCards={4} disableDecoration>
|
<CardScroller title="Episodes" displayCards={4} disableDecoration>
|
||||||
{episodes.data.SearchHints?.map((episode) => {
|
{episodes.data.SearchHints?.map((episode) => {
|
||||||
return (
|
return (
|
||||||
<EpisodeCard
|
<Card
|
||||||
key={episode.Id}
|
key={episode.Id}
|
||||||
item={episode}
|
item={episode}
|
||||||
cardTitle={episode.Series}
|
cardTitle={episode.Series}
|
||||||
|
cardType="thumb"
|
||||||
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||||
queryKey={["search", "items", "Episodes", query]}
|
queryKey={["search", "items", "Episodes", query]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
disableRunTime
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ import {
|
|||||||
} from "@/utils/date/time";
|
} from "@/utils/date/time";
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { EpisodeCard } from "@/components/card/episodeCard";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { CardScroller } from "@/components/cardScroller/cardScroller";
|
|
||||||
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import "./series.scss";
|
import "./series.scss";
|
||||||
@@ -885,33 +884,6 @@ function SeriesTitlePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{nextUpEpisode.isSuccess && nextUpEpisode.data.TotalRecordCount > 0 && (
|
|
||||||
<CardScroller title="Next Up" displayCards={4} disableDecoration>
|
|
||||||
{nextUpEpisode.data.Items.map((episode) => {
|
|
||||||
return (
|
|
||||||
<EpisodeCard
|
|
||||||
key={episode.Id}
|
|
||||||
item={episode}
|
|
||||||
cardTitle={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
|
||||||
cardCaption={episode.Overview}
|
|
||||||
imageBlurhash={
|
|
||||||
episode.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(episode.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
queryKey={[
|
|
||||||
"item",
|
|
||||||
id,
|
|
||||||
`season ${currentSeason + 1}`,
|
|
||||||
"episodes",
|
|
||||||
]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{seasons.isPending ? (
|
{seasons.isPending ? (
|
||||||
<SeasonSelectorSkeleton />
|
<SeasonSelectorSkeleton />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in new issue
Block a user