refactor: remove redundant calls for getCurrentUser
This commit is contained in:
35 files changed
+651
-690
No files matched your search
@@ -11,7 +11,6 @@ import useScrollTrigger from "@mui/material/useScrollTrigger";
|
|||||||
|
|
||||||
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
@@ -35,6 +34,7 @@ import {
|
|||||||
ListItemText,
|
ListItemText,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import BackButton from "../buttons/backButton";
|
import BackButton from "../buttons/backButton";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
interface ListItemLinkProps {
|
interface ListItemLinkProps {
|
||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
@@ -77,24 +77,16 @@ export const AppBar = () => {
|
|||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
enabled: display && Boolean(api?.accessToken),
|
|
||||||
throwOnError: true,
|
|
||||||
});
|
|
||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data && !!api.accessToken,
|
enabled: !!user?.Id && !!api.accessToken,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,19 +171,18 @@ export const AppBar = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||||
<IconButton onClick={() => navigate({ to: "/search" })}>
|
<IconButton
|
||||||
|
onClick={() => navigate({ to: "/search", params: { query: "" } })}
|
||||||
|
>
|
||||||
<div className="material-symbols-rounded">search</div>
|
<div className="material-symbols-rounded">search</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton onClick={() => navigate({ to: "/favorite" })}>
|
<IconButton onClick={() => navigate({ to: "/favorite" })}>
|
||||||
<div className="material-symbols-rounded">favorite</div>
|
<div className="material-symbols-rounded">favorite</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton sx={{ p: 0 }} onClick={handleMenuOpen}>
|
<IconButton sx={{ p: 0 }} onClick={handleMenuOpen}>
|
||||||
{user.isSuccess &&
|
{!!user?.Id &&
|
||||||
(user.data.PrimaryImageTag === undefined ? (
|
(user?.PrimaryImageTag === undefined ? (
|
||||||
<Avatar
|
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||||
className="appBar-avatar"
|
|
||||||
alt={user.data.Name ?? "image"}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||||
account_circle
|
account_circle
|
||||||
</span>
|
</span>
|
||||||
@@ -199,8 +190,8 @@ export const AppBar = () => {
|
|||||||
) : (
|
) : (
|
||||||
<Avatar
|
<Avatar
|
||||||
className="appBar-avatar"
|
className="appBar-avatar"
|
||||||
src={`${api.basePath}/Users/${user.data.Id}/Images/Primary`}
|
src={`${api.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||||
alt={user.data.Name ?? "image"}
|
alt={user?.Name ?? "image"}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||||
account_circle
|
account_circle
|
||||||
@@ -281,12 +272,12 @@ export const AppBar = () => {
|
|||||||
<List>
|
<List>
|
||||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
<ListItemLink to="/home" icon="home" primary="Home" />
|
||||||
{libraries.isSuccess &&
|
{libraries.isSuccess &&
|
||||||
libraries.data.Items?.map((library, index) => (
|
libraries.data.Items?.map((library) => (
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
key={library.Id}
|
key={library.Id}
|
||||||
to={`/library/${library.Id}`}
|
to={`/library/${library.Id}`}
|
||||||
icon={getTypeIcon(library.CollectionType)}
|
icon={getTypeIcon(library.CollectionType)}
|
||||||
primary={library.Name}
|
primary={library.Name ?? "Library"}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type PlayButtonProps = {
|
|||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
itemId: string;
|
itemId: string;
|
||||||
itemUserData: UserItemDataDto;
|
itemUserData: UserItemDataDto;
|
||||||
userId: string;
|
userId: string | undefined;
|
||||||
itemType: BaseItemKind;
|
itemType: BaseItemKind;
|
||||||
currentAudioTrack: number;
|
currentAudioTrack: number;
|
||||||
currentVideoTrack: number;
|
currentVideoTrack: number;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ $image-size: 5em;
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.2em;
|
gap: 0.2em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-item.Mui-disabled {
|
&-item.Mui-disabled {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import "./queueButton.scss";
|
import "./queueButton.scss";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
@@ -29,7 +28,7 @@ const QueueButton = () => {
|
|||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const [buttonEl, setButtonEl] = useState(null);
|
const [buttonEl, setButtonEl] = useState<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
const handlePlay = useMutation({
|
const handlePlay = useMutation({
|
||||||
mutationKey: ["handlePlayIndex"],
|
mutationKey: ["handlePlayIndex"],
|
||||||
@@ -76,13 +75,105 @@ const QueueButton = () => {
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{queueItems[currentItemIndex].Id && (
|
||||||
|
<>
|
||||||
|
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
||||||
|
Currently Playing:
|
||||||
|
</Typography>
|
||||||
|
<MenuItem
|
||||||
|
className="queue-item"
|
||||||
|
disabled
|
||||||
|
key={queueItems[currentItemIndex].Id}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2">
|
||||||
|
{queueItems[currentItemIndex]?.Type === "Audio"
|
||||||
|
? currentItemIndex + 1
|
||||||
|
: queueItems[currentItemIndex].IndexNumberEnd
|
||||||
|
? `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber} / ${queueItems[currentItemIndex].IndexNumberEnd}`
|
||||||
|
: `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber}`}
|
||||||
|
</Typography>
|
||||||
|
<div className="queue-item-image-container">
|
||||||
|
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
||||||
|
<img
|
||||||
|
className="queue-item-image"
|
||||||
|
src={api?.getItemImageUrl(
|
||||||
|
queueItems[currentItemIndex]?.Id,
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
tag: queueItems[currentItemIndex].ImageTags?.Primary,
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
|
/>
|
||||||
|
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
||||||
|
?.length ?? -1) > 0 ? (
|
||||||
|
<img
|
||||||
|
className="queue-item-image"
|
||||||
|
src={api?.getItemImageUrl(
|
||||||
|
queueItems[currentItemIndex]?.AlbumId,
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
tag: queueItems[currentItemIndex]
|
||||||
|
.AlbumPrimaryImageTag[0],
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="queue-item-image-icon">
|
||||||
|
{queueItems[currentItemIndex].Type &&
|
||||||
|
getTypeIcon(queueItems[currentItemIndex].Type)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%,-50%)",
|
||||||
|
fontSize: "2em",
|
||||||
|
"--wght": "100",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
equalizer
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="queue-item-info">
|
||||||
|
{queueItems[currentItemIndex].SeriesName ? (
|
||||||
|
<>
|
||||||
|
<Typography variant="subtitle1" width="100%">
|
||||||
|
{queueItems[currentItemIndex].SeriesName}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
width="100%"
|
||||||
|
style={{ opacity: 0.6 }}
|
||||||
|
>
|
||||||
|
{queueItems[currentItemIndex].Name}
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Typography variant="subtitle1" width="100%">
|
||||||
|
{queueItems[currentItemIndex].Name}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</MenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
|
.length > 0 && (
|
||||||
|
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
||||||
|
Queue:
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
{queueItems
|
{queueItems
|
||||||
.slice(currentItemIndex, queueItems.length - 1)
|
.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
.map((item, index) => {
|
.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
className="queue-item"
|
className="queue-item"
|
||||||
disabled={index === 0}
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handlePlay.mutate({ index: index + currentItemIndex })
|
handlePlay.mutate({ index: index + currentItemIndex })
|
||||||
}
|
}
|
||||||
@@ -102,41 +193,30 @@ const QueueButton = () => {
|
|||||||
src={api?.getItemImageUrl(item?.Id, "Primary", {
|
src={api?.getItemImageUrl(item?.Id, "Primary", {
|
||||||
tag: item.ImageTags?.Primary,
|
tag: item.ImageTags?.Primary,
|
||||||
})}
|
})}
|
||||||
alt={item.Name}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : item.AlbumPrimaryImageTag?.length > 0 ? (
|
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={api?.getItemImageUrl(item?.AlbumId, "Primary", {
|
src={api?.getItemImageUrl(item?.AlbumId, "Primary", {
|
||||||
tag: item.AlbumPrimaryImageTag[0],
|
tag: item.AlbumPrimaryImageTag[0],
|
||||||
})}
|
})}
|
||||||
alt={item.Name}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="queue-item-image-icon">
|
<div className="queue-item-image-icon">
|
||||||
{getTypeIcon(item.Type)}
|
{item.Type && getTypeIcon(item.Type)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{index === 0 && (
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%,-50%)",
|
|
||||||
fontSize: "2em",
|
|
||||||
"--wght": "100",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
equalizer
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="queue-item-info">
|
<div className="queue-item-info">
|
||||||
{item.SeriesName ? (
|
{item.SeriesName ? (
|
||||||
<>
|
<>
|
||||||
<Typography variant="subtitle1" width="100%">
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
|
width="100%"
|
||||||
|
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||||
|
>
|
||||||
{item.SeriesName}
|
{item.SeriesName}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -148,9 +228,23 @@ const QueueButton = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Typography variant="subtitle1" width="100%">
|
<>
|
||||||
{item.Name}
|
<Typography
|
||||||
</Typography>
|
variant="subtitle1"
|
||||||
|
width="100%"
|
||||||
|
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||||
|
>
|
||||||
|
{item.Name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
width="100%"
|
||||||
|
style={{ opacity: 0.6 }}
|
||||||
|
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||||
|
>
|
||||||
|
{item.Artists?.join(", ")}
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const CardComponent = ({
|
|||||||
disableOverlay = false,
|
disableOverlay = false,
|
||||||
overrideIcon,
|
overrideIcon,
|
||||||
}: {
|
}: {
|
||||||
item: BaseItemDto | null;
|
item: BaseItemDto;
|
||||||
cardTitle: string | undefined | null;
|
cardTitle: string | undefined | null;
|
||||||
cardCaption?: string | null | number;
|
cardCaption?: string | null | number;
|
||||||
imageType: ImageType;
|
imageType: ImageType;
|
||||||
@@ -65,31 +65,33 @@ const CardComponent = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const defaultOnClick = () => {
|
const defaultOnClick = () => {
|
||||||
switch (item.Type) {
|
if (item?.Id) {
|
||||||
case BaseItemKind.BoxSet:
|
switch (item?.Type) {
|
||||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
case BaseItemKind.BoxSet:
|
||||||
break;
|
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Episode:
|
break;
|
||||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
case BaseItemKind.Episode:
|
||||||
break;
|
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.MusicAlbum:
|
break;
|
||||||
navigate({ to: "/album/$id", params: { id: item.Id } });
|
case BaseItemKind.MusicAlbum:
|
||||||
break;
|
navigate({ to: "/album/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.MusicArtist:
|
break;
|
||||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
case BaseItemKind.MusicArtist:
|
||||||
break;
|
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Person:
|
break;
|
||||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
case BaseItemKind.Person:
|
||||||
break;
|
navigate({ to: "/person/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Series:
|
break;
|
||||||
navigate({ to: "/series/$id", params: { id: item.Id } });
|
case BaseItemKind.Series:
|
||||||
break;
|
navigate({ to: "/series/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Playlist:
|
break;
|
||||||
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
case BaseItemKind.Playlist:
|
||||||
break;
|
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
||||||
default:
|
break;
|
||||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
default:
|
||||||
break;
|
navigate({ to: "/item/$id", params: { id: item.Id } });
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -129,7 +131,7 @@ const CardComponent = ({
|
|||||||
overrideIcon === "User"
|
overrideIcon === "User"
|
||||||
? `${api.basePath}/Users/${item.Id}/Images/Primary`
|
? `${api.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
: api.getItemImageUrl(
|
: api.getItemImageUrl(
|
||||||
seriesId ? item.SeriesId : item.AlbumId ?? item.Id,
|
seriesId ? item.SeriesId : (item.AlbumId ?? item.Id),
|
||||||
imageType,
|
imageType,
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ export const CardScroller = ({
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const [carouselRef, setCarouselRef] = useState();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box {...boxProps} className="card-scroller-container" mb={1}>
|
<Box {...boxProps} className="card-scroller-container" mb={1}>
|
||||||
<Box
|
<Box
|
||||||
@@ -79,7 +77,7 @@ export const CardScroller = ({
|
|||||||
draggable
|
draggable
|
||||||
responsive={responsive}
|
responsive={responsive}
|
||||||
arrows
|
arrows
|
||||||
ref={(el) => setCarouselRef(el)}
|
rtl={false}
|
||||||
className="card-scroller"
|
className="card-scroller"
|
||||||
customTransition="all .6s"
|
customTransition="all .6s"
|
||||||
transitionDuration={600}
|
transitionDuration={600}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { yellow } from "@mui/material/colors";
|
|||||||
|
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
import { green, red } from "@mui/material/colors";
|
import { green, red } from "@mui/material/colors";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
@@ -23,66 +22,45 @@ import {
|
|||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
const availableSpecialRoutes = [
|
|
||||||
BaseItemKind.Series,
|
|
||||||
BaseItemKind.BoxSet,
|
|
||||||
BaseItemKind.MusicAlbum,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Carousel slide component
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleMoreInfo = () => {
|
const handleMoreInfo = () => {
|
||||||
switch (item.Type) {
|
if (item.Id) {
|
||||||
case BaseItemKind.BoxSet:
|
switch (item.Type) {
|
||||||
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
case BaseItemKind.BoxSet:
|
||||||
break;
|
navigate({ to: "/boxset/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Episode:
|
break;
|
||||||
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
case BaseItemKind.Episode:
|
||||||
break;
|
navigate({ to: "/episode/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.MusicAlbum:
|
break;
|
||||||
navigate({ to: "/album/$id", params: { id: item.Id } });
|
case BaseItemKind.MusicAlbum:
|
||||||
break;
|
navigate({ to: "/album/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.MusicArtist:
|
break;
|
||||||
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
case BaseItemKind.MusicArtist:
|
||||||
break;
|
navigate({ to: "/artist/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Person:
|
break;
|
||||||
navigate({ to: "/person/$id", params: { id: item.Id } });
|
case BaseItemKind.Person:
|
||||||
break;
|
navigate({ to: "/person/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Series:
|
break;
|
||||||
navigate({ to: "/series/$id", params: { id: item.Id } });
|
case BaseItemKind.Series:
|
||||||
break;
|
navigate({ to: "/series/$id", params: { id: item.Id } });
|
||||||
case BaseItemKind.Playlist:
|
break;
|
||||||
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
case BaseItemKind.Playlist:
|
||||||
break;
|
navigate({ to: "/playlist/$id", params: { id: item.Id } });
|
||||||
default:
|
break;
|
||||||
navigate({ to: "/item/$id", params: { id: item.Id } });
|
default:
|
||||||
break;
|
navigate({ to: "/item/$id", params: { id: item.Id } });
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -100,7 +78,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
<div className="hero-carousel-background-container">
|
<div className="hero-carousel-background-container">
|
||||||
{item.BackdropImageTags?.length ? (
|
{item.BackdropImageTags?.length ? (
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "item"}
|
||||||
className="hero-carousel-background-image"
|
className="hero-carousel-background-image"
|
||||||
src={
|
src={
|
||||||
item.ParentBackdropItemId
|
item.ParentBackdropItemId
|
||||||
@@ -155,7 +133,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
fontWeight={200}
|
fontWeight={200}
|
||||||
overflow="visible"
|
overflow="visible"
|
||||||
>
|
>
|
||||||
{!item.ImageTags.Logo ? (
|
{!item.ImageTags?.Logo ? (
|
||||||
item.Name
|
item.Name
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
@@ -336,7 +314,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
itemType={item.Type}
|
itemType={item.Type}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack={0}
|
currentSubTrack={0}
|
||||||
@@ -377,15 +355,15 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
queryKey={["home", "latestMedia"]}
|
queryKey={["home", "latestMedia"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
isFavorite={item.UserData.IsFavorite}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
queryKey={["home", "latestMedia"]}
|
queryKey={["home", "latestMedia"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
isPlayed={item.UserData.Played}
|
isPlayed={item.UserData?.Played}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
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 { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Latest Media Section
|
* @description Latest Media Section
|
||||||
@@ -19,17 +20,10 @@ export const LatestMediaSection = ({
|
|||||||
latestMediaLib,
|
latestMediaLib,
|
||||||
}: { latestMediaLib: BaseItemDto }) => {
|
}: { latestMediaLib: BaseItemDto }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
const fetchLatestMedia = async (library: BaseItemDto) => {
|
const fetchLatestMedia = async (library: BaseItemDto) => {
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: library.Id,
|
parentId: library.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
fields: ["PrimaryImageAspectRatio"],
|
fields: ["PrimaryImageAspectRatio"],
|
||||||
@@ -39,7 +33,7 @@ export const LatestMediaSection = ({
|
|||||||
const data = useQuery({
|
const data = useQuery({
|
||||||
queryKey: ["home", "latestMedia", latestMediaLib.Id],
|
queryKey: ["home", "latestMedia", latestMediaLib.Id],
|
||||||
queryFn: () => fetchLatestMedia(latestMediaLib),
|
queryFn: () => fetchLatestMedia(latestMediaLib),
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
refetchOnMount: true,
|
refetchOnMount: true,
|
||||||
});
|
});
|
||||||
if (data.isPending) {
|
if (data.isPending) {
|
||||||
@@ -80,7 +74,7 @@ export const LatestMediaSection = ({
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { red } from "@mui/material/colors";
|
import { red } from "@mui/material/colors";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
export const ErrorNotice = ({ error }: { error?: Error }) => {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -23,14 +22,15 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
|||||||
style={{
|
style={{
|
||||||
fontSize: "10em",
|
fontSize: "10em",
|
||||||
color: red[800],
|
color: red[800],
|
||||||
|
//@ts-ignore
|
||||||
"--clr": "rgb(198 40 40 / 30%)",
|
"--clr": "rgb(198 40 40 / 30%)",
|
||||||
fontVariationSettings: '"FILL" 1, "wght" 400, "GRAD" 25, "opsz" 60',
|
fontVariationSettings: '"FILL" 1, "wght" 400, "GRAD" 25, "opsz" 60',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
error
|
error
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="h3" fontWeight={300}>
|
<Typography variant="h3" color="white" fontWeight={300}>
|
||||||
Something went wrong
|
Something went wrong.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
fontFamily="JetBrains Mono Variable"
|
fontFamily="JetBrains Mono Variable"
|
||||||
@@ -45,8 +45,9 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
// opacity: 0.6,
|
// opacity: 0.6,
|
||||||
}}
|
}}
|
||||||
|
color="gray"
|
||||||
>
|
>
|
||||||
{JSON.stringify(error.message)}
|
{JSON.stringify(error?.message)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,24 +1,12 @@
|
|||||||
import React, {
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
useEffect,
|
|
||||||
useLayoutEffect,
|
|
||||||
useMemo,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import Grow from "@mui/material/Grow";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Popper from "@mui/material/Popper";
|
|
||||||
import Slider from "@mui/material/Slider";
|
import Slider from "@mui/material/Slider";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import WaveSurfer from "wavesurfer.js";
|
|
||||||
|
|
||||||
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
|
|
||||||
@@ -26,14 +14,16 @@ import { AnimatePresence } from "framer-motion";
|
|||||||
import "./audioPlayer.scss";
|
import "./audioPlayer.scss";
|
||||||
|
|
||||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||||
import QueueButton from "@/components/buttons/queueButton";
|
import QueueButton from "@/components/buttons/queueButton";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
const AudioPlayer = () => {
|
const AudioPlayer = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -49,17 +39,7 @@ const AudioPlayer = () => {
|
|||||||
state.currentItemIndex,
|
state.currentItemIndex,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(display) && Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const waveSurferContainerRef = useRef(null);
|
|
||||||
|
|
||||||
const playing = useMemo(() => {
|
const playing = useMemo(() => {
|
||||||
if (audioRef.current?.paused) return false;
|
if (audioRef.current?.paused) return false;
|
||||||
@@ -70,7 +50,7 @@ const AudioPlayer = () => {
|
|||||||
const [isMuted, setIsMuted] = useState(false);
|
const [isMuted, setIsMuted] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||||
const [sliderProgress, setSliderProgress] = useState(false);
|
const [sliderProgress, setSliderProgress] = useState(0);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
@@ -113,7 +93,7 @@ const AudioPlayer = () => {
|
|||||||
>
|
>
|
||||||
<div className="audio-player-image-container">
|
<div className="audio-player-image-container">
|
||||||
<img
|
<img
|
||||||
alt={tracks[currentTrack]?.Name}
|
alt={tracks[currentTrack]?.Name ?? "track"}
|
||||||
className="audio-player-image"
|
className="audio-player-image"
|
||||||
src={api?.getItemImageUrl(
|
src={api?.getItemImageUrl(
|
||||||
!item?.ImageTags.Primary ? item?.AlbumId : item?.Id,
|
!item?.ImageTags.Primary ? item?.AlbumId : item?.Id,
|
||||||
@@ -145,7 +125,7 @@ const AudioPlayer = () => {
|
|||||||
}}
|
}}
|
||||||
noWrap
|
noWrap
|
||||||
>
|
>
|
||||||
by {item?.Artists.map((artist) => artist).join(",")}
|
by {item?.Artists?.map((artist) => artist).join(",")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -215,8 +195,10 @@ const AudioPlayer = () => {
|
|||||||
value={isMuted ? 0 : volume * 100}
|
value={isMuted ? 0 : volume * 100}
|
||||||
step={1}
|
step={1}
|
||||||
max={100}
|
max={100}
|
||||||
onChange={(e, newVal) => {
|
onChange={(_, newVal) => {
|
||||||
setVolume(newVal / 100);
|
Array.isArray(newVal)
|
||||||
|
? setVolume(newVal[0] / 100)
|
||||||
|
: setVolume(newVal / 100);
|
||||||
audioRef.current.volume = newVal / 100;
|
audioRef.current.volume = newVal / 100;
|
||||||
}}
|
}}
|
||||||
valueLabelDisplay="auto"
|
valueLabelDisplay="auto"
|
||||||
@@ -260,6 +242,14 @@ const AudioPlayer = () => {
|
|||||||
[volume, isMuted, currentTrack],
|
[volume, isMuted, currentTrack],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (audioRef.current) {
|
||||||
|
audioRef.current.addEventListener("ended", () => {
|
||||||
|
if (tracks[currentTrack + 1]?.Id) {
|
||||||
|
playItemFromQueue("next", user?.Id, api);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence mode="sync">
|
<AnimatePresence mode="sync">
|
||||||
{display && (
|
{display && (
|
||||||
@@ -319,12 +309,14 @@ const AudioPlayer = () => {
|
|||||||
value={isScrubbing ? sliderProgress : progress}
|
value={isScrubbing ? sliderProgress : progress}
|
||||||
step={1}
|
step={1}
|
||||||
size="small"
|
size="small"
|
||||||
max={item?.RunTimeTicks}
|
max={item?.RunTimeTicks ?? 1}
|
||||||
onChange={(e, value) => {
|
onChange={(_, value) => {
|
||||||
setIsScrubbing(true);
|
setIsScrubbing(true);
|
||||||
setSliderProgress(value);
|
Array.isArray(value)
|
||||||
|
? setSliderProgress(value[0])
|
||||||
|
: setSliderProgress(value);
|
||||||
}}
|
}}
|
||||||
onChangeCommitted={(e, value) => {
|
onChangeCommitted={(_, value) => {
|
||||||
setIsScrubbing(false);
|
setIsScrubbing(false);
|
||||||
// console.log(ticksToSec(value * item?.RunTimeTicks));
|
// console.log(ticksToSec(value * item?.RunTimeTicks));
|
||||||
setProgress(value);
|
setProgress(value);
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import Button from "@mui/material/Button";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
const ShowMoreText = ({ content, collapsedLines, extraProps }) => {
|
const ShowMoreText = ({
|
||||||
|
content,
|
||||||
|
collapsedLines,
|
||||||
|
extraProps,
|
||||||
|
}: { content: string; collapsedLines: number; extraProps?: unknown }) => {
|
||||||
const [displayFull, setDisplayFull] = useState(false);
|
const [displayFull, setDisplayFull] = useState(false);
|
||||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||||
const textRef = useRef(null);
|
const textRef = useRef(null);
|
||||||
@@ -34,7 +38,7 @@ const ShowMoreText = ({ content, collapsedLines, extraProps }) => {
|
|||||||
display: "-webkit-box",
|
display: "-webkit-box",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
WebkitLineClamp: displayFull ? "none" : collapsedLines ?? 2,
|
WebkitLineClamp: displayFull ? "none" : (collapsedLines ?? 2),
|
||||||
WebkitBoxOrient: "vertical",
|
WebkitBoxOrient: "vertical",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
}}
|
}}
|
||||||
+28
-11
@@ -1,9 +1,9 @@
|
|||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
||||||
import {
|
import {
|
||||||
RouterProvider,
|
QueryClient,
|
||||||
createRouteMask,
|
QueryClientProvider,
|
||||||
createRouter,
|
useQuery,
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-query";
|
||||||
|
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
||||||
import React, { Suspense } from "react";
|
import React, { Suspense } from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
// Import the generated route tree
|
// Import the generated route tree
|
||||||
@@ -25,6 +25,7 @@ const router = createRouter({
|
|||||||
createApi: undefined!,
|
createApi: undefined!,
|
||||||
user: undefined,
|
user: undefined,
|
||||||
jellyfinSDK: undefined!,
|
jellyfinSDK: undefined!,
|
||||||
|
fetchCurrentUser: undefined!,
|
||||||
},
|
},
|
||||||
defaultPreload: "intent",
|
defaultPreload: "intent",
|
||||||
});
|
});
|
||||||
@@ -37,6 +38,10 @@ declare module "@tanstack/react-router" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import { ApiProvider, useApiInContext } from "./utils/store/api";
|
import { ApiProvider, useApiInContext } from "./utils/store/api";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { ErrorNotice } from "./components/notices/errorNotice/errorNotice";
|
||||||
|
import { CentralProvider, useCentralStore } from "./utils/store/central";
|
||||||
|
|
||||||
export const queryClient = new QueryClient({
|
export const queryClient = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
@@ -55,8 +60,16 @@ function ProviderWrapper() {
|
|||||||
s.createApi,
|
s.createApi,
|
||||||
s.jellyfin,
|
s.jellyfin,
|
||||||
]);
|
]);
|
||||||
|
const [user, fetchCurrentUser] = useCentralStore((s) => [
|
||||||
|
s.currentUser,
|
||||||
|
s.fetchCurrentUser,
|
||||||
|
]);
|
||||||
|
if (api?.accessToken) fetchCurrentUser(api);
|
||||||
return (
|
return (
|
||||||
<RouterProvider router={router} context={{ api, createApi, jellyfinSDK }} />
|
<RouterProvider
|
||||||
|
router={router}
|
||||||
|
context={{ api, createApi, user, jellyfinSDK, fetchCurrentUser }}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,11 +77,15 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
|
|||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
{/* TODO: Create a proper loading fallback component */}
|
{/* TODO: Create a proper loading fallback component */}
|
||||||
<Suspense fallback={<h1>Loading in main.tsx</h1>}>
|
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||||
<ApiProvider>
|
<Suspense fallback={<h1>Loading in main.tsx</h1>}>
|
||||||
<ProviderWrapper />
|
<CentralProvider>
|
||||||
</ApiProvider>
|
<ApiProvider>
|
||||||
</Suspense>
|
<ProviderWrapper />
|
||||||
|
</ApiProvider>
|
||||||
|
</CentralProvider>
|
||||||
|
</Suspense>
|
||||||
|
</ErrorBoundary>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
);
|
);
|
||||||
|
|||||||
+8
-46
@@ -16,7 +16,6 @@ import { Route as IndexImport } from './routes/index'
|
|||||||
import { Route as ErrorCodeImport } from './routes/error/$code'
|
import { Route as ErrorCodeImport } from './routes/error/$code'
|
||||||
import { Route as ApiSearchImport } from './routes/_api/search'
|
import { Route as ApiSearchImport } from './routes/_api/search'
|
||||||
import { Route as ApiLoginImport } from './routes/_api/login'
|
import { Route as ApiLoginImport } from './routes/_api/login'
|
||||||
import { Route as ApiLibraryImport } from './routes/_api/library'
|
|
||||||
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
||||||
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
||||||
import { Route as ApiHomeIndexImport } from './routes/_api/home/index'
|
import { Route as ApiHomeIndexImport } from './routes/_api/home/index'
|
||||||
@@ -65,11 +64,6 @@ const ApiLoginRoute = ApiLoginImport.update({
|
|||||||
getParentRoute: () => ApiRoute,
|
getParentRoute: () => ApiRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiLibraryRoute = ApiLibraryImport.update({
|
|
||||||
path: '/library',
|
|
||||||
getParentRoute: () => ApiRoute,
|
|
||||||
} as any)
|
|
||||||
|
|
||||||
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
||||||
path: '/',
|
path: '/',
|
||||||
getParentRoute: () => ApiSearchRoute,
|
getParentRoute: () => ApiSearchRoute,
|
||||||
@@ -136,8 +130,8 @@ const ApiLoginListRoute = ApiLoginListImport.update({
|
|||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiLibraryIdRoute = ApiLibraryIdImport.update({
|
const ApiLibraryIdRoute = ApiLibraryIdImport.update({
|
||||||
path: '/$id',
|
path: '/library/$id',
|
||||||
getParentRoute: () => ApiLibraryRoute,
|
getParentRoute: () => ApiRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiItemIdRoute = ApiItemIdImport.update({
|
const ApiItemIdRoute = ApiItemIdImport.update({
|
||||||
@@ -188,13 +182,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiImport
|
preLoaderRoute: typeof ApiImport
|
||||||
parentRoute: typeof rootRoute
|
parentRoute: typeof rootRoute
|
||||||
}
|
}
|
||||||
'/_api/library': {
|
|
||||||
id: '/_api/library'
|
|
||||||
path: '/library'
|
|
||||||
fullPath: '/library'
|
|
||||||
preLoaderRoute: typeof ApiLibraryImport
|
|
||||||
parentRoute: typeof ApiImport
|
|
||||||
}
|
|
||||||
'/_api/login': {
|
'/_api/login': {
|
||||||
id: '/_api/login'
|
id: '/_api/login'
|
||||||
path: '/login'
|
path: '/login'
|
||||||
@@ -253,10 +240,10 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
'/_api/library/$id': {
|
'/_api/library/$id': {
|
||||||
id: '/_api/library/$id'
|
id: '/_api/library/$id'
|
||||||
path: '/$id'
|
path: '/library/$id'
|
||||||
fullPath: '/library/$id'
|
fullPath: '/library/$id'
|
||||||
preLoaderRoute: typeof ApiLibraryIdImport
|
preLoaderRoute: typeof ApiLibraryIdImport
|
||||||
parentRoute: typeof ApiLibraryImport
|
parentRoute: typeof ApiImport
|
||||||
}
|
}
|
||||||
'/_api/login/list': {
|
'/_api/login/list': {
|
||||||
id: '/_api/login/list'
|
id: '/_api/login/list'
|
||||||
@@ -361,18 +348,6 @@ declare module '@tanstack/react-router' {
|
|||||||
|
|
||||||
// Create and export the route tree
|
// Create and export the route tree
|
||||||
|
|
||||||
interface ApiLibraryRouteChildren {
|
|
||||||
ApiLibraryIdRoute: typeof ApiLibraryIdRoute
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiLibraryRouteChildren: ApiLibraryRouteChildren = {
|
|
||||||
ApiLibraryIdRoute: ApiLibraryIdRoute,
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiLibraryRouteWithChildren = ApiLibraryRoute._addFileChildren(
|
|
||||||
ApiLibraryRouteChildren,
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ApiLoginRouteChildren {
|
interface ApiLoginRouteChildren {
|
||||||
ApiLoginListRoute: typeof ApiLoginListRoute
|
ApiLoginListRoute: typeof ApiLoginListRoute
|
||||||
ApiLoginManualRoute: typeof ApiLoginManualRoute
|
ApiLoginManualRoute: typeof ApiLoginManualRoute
|
||||||
@@ -402,7 +377,6 @@ const ApiSearchRouteWithChildren = ApiSearchRoute._addFileChildren(
|
|||||||
)
|
)
|
||||||
|
|
||||||
interface ApiRouteChildren {
|
interface ApiRouteChildren {
|
||||||
ApiLibraryRoute: typeof ApiLibraryRouteWithChildren
|
|
||||||
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
||||||
ApiSearchRoute: typeof ApiSearchRouteWithChildren
|
ApiSearchRoute: typeof ApiSearchRouteWithChildren
|
||||||
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
||||||
@@ -410,6 +384,7 @@ interface ApiRouteChildren {
|
|||||||
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
||||||
ApiEpisodeIdRoute: typeof ApiEpisodeIdRoute
|
ApiEpisodeIdRoute: typeof ApiEpisodeIdRoute
|
||||||
ApiItemIdRoute: typeof ApiItemIdRoute
|
ApiItemIdRoute: typeof ApiItemIdRoute
|
||||||
|
ApiLibraryIdRoute: typeof ApiLibraryIdRoute
|
||||||
ApiPersonIdRoute: typeof ApiPersonIdRoute
|
ApiPersonIdRoute: typeof ApiPersonIdRoute
|
||||||
ApiPlayerAudioRoute: typeof ApiPlayerAudioRoute
|
ApiPlayerAudioRoute: typeof ApiPlayerAudioRoute
|
||||||
ApiPlaylistIdRoute: typeof ApiPlaylistIdRoute
|
ApiPlaylistIdRoute: typeof ApiPlaylistIdRoute
|
||||||
@@ -420,7 +395,6 @@ interface ApiRouteChildren {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ApiRouteChildren: ApiRouteChildren = {
|
const ApiRouteChildren: ApiRouteChildren = {
|
||||||
ApiLibraryRoute: ApiLibraryRouteWithChildren,
|
|
||||||
ApiLoginRoute: ApiLoginRouteWithChildren,
|
ApiLoginRoute: ApiLoginRouteWithChildren,
|
||||||
ApiSearchRoute: ApiSearchRouteWithChildren,
|
ApiSearchRoute: ApiSearchRouteWithChildren,
|
||||||
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
||||||
@@ -428,6 +402,7 @@ const ApiRouteChildren: ApiRouteChildren = {
|
|||||||
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
||||||
ApiEpisodeIdRoute: ApiEpisodeIdRoute,
|
ApiEpisodeIdRoute: ApiEpisodeIdRoute,
|
||||||
ApiItemIdRoute: ApiItemIdRoute,
|
ApiItemIdRoute: ApiItemIdRoute,
|
||||||
|
ApiLibraryIdRoute: ApiLibraryIdRoute,
|
||||||
ApiPersonIdRoute: ApiPersonIdRoute,
|
ApiPersonIdRoute: ApiPersonIdRoute,
|
||||||
ApiPlayerAudioRoute: ApiPlayerAudioRoute,
|
ApiPlayerAudioRoute: ApiPlayerAudioRoute,
|
||||||
ApiPlaylistIdRoute: ApiPlaylistIdRoute,
|
ApiPlaylistIdRoute: ApiPlaylistIdRoute,
|
||||||
@@ -442,7 +417,6 @@ const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren)
|
|||||||
export interface FileRoutesByFullPath {
|
export interface FileRoutesByFullPath {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'': typeof ApiRouteWithChildren
|
'': typeof ApiRouteWithChildren
|
||||||
'/library': typeof ApiLibraryRouteWithChildren
|
|
||||||
'/login': typeof ApiLoginRouteWithChildren
|
'/login': typeof ApiLoginRouteWithChildren
|
||||||
'/search': typeof ApiSearchRouteWithChildren
|
'/search': typeof ApiSearchRouteWithChildren
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
@@ -471,7 +445,6 @@ export interface FileRoutesByFullPath {
|
|||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'': typeof ApiRouteWithChildren
|
'': typeof ApiRouteWithChildren
|
||||||
'/library': typeof ApiLibraryRouteWithChildren
|
|
||||||
'/login': typeof ApiLoginRouteWithChildren
|
'/login': typeof ApiLoginRouteWithChildren
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
'/album/$id': typeof ApiAlbumIdRoute
|
'/album/$id': typeof ApiAlbumIdRoute
|
||||||
@@ -500,7 +473,6 @@ export interface FileRoutesById {
|
|||||||
__root__: typeof rootRoute
|
__root__: typeof rootRoute
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/_api': typeof ApiRouteWithChildren
|
'/_api': typeof ApiRouteWithChildren
|
||||||
'/_api/library': typeof ApiLibraryRouteWithChildren
|
|
||||||
'/_api/login': typeof ApiLoginRouteWithChildren
|
'/_api/login': typeof ApiLoginRouteWithChildren
|
||||||
'/_api/search': typeof ApiSearchRouteWithChildren
|
'/_api/search': typeof ApiSearchRouteWithChildren
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
@@ -531,7 +503,6 @@ export interface FileRouteTypes {
|
|||||||
fullPaths:
|
fullPaths:
|
||||||
| '/'
|
| '/'
|
||||||
| ''
|
| ''
|
||||||
| '/library'
|
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/search'
|
| '/search'
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
@@ -559,7 +530,6 @@ export interface FileRouteTypes {
|
|||||||
to:
|
to:
|
||||||
| '/'
|
| '/'
|
||||||
| ''
|
| ''
|
||||||
| '/library'
|
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
| '/album/$id'
|
| '/album/$id'
|
||||||
@@ -586,7 +556,6 @@ export interface FileRouteTypes {
|
|||||||
| '__root__'
|
| '__root__'
|
||||||
| '/'
|
| '/'
|
||||||
| '/_api'
|
| '/_api'
|
||||||
| '/_api/library'
|
|
||||||
| '/_api/login'
|
| '/_api/login'
|
||||||
| '/_api/search'
|
| '/_api/search'
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
@@ -657,7 +626,6 @@ export const routeTree = rootRoute
|
|||||||
"/_api": {
|
"/_api": {
|
||||||
"filePath": "_api.tsx",
|
"filePath": "_api.tsx",
|
||||||
"children": [
|
"children": [
|
||||||
"/_api/library",
|
|
||||||
"/_api/login",
|
"/_api/login",
|
||||||
"/_api/search",
|
"/_api/search",
|
||||||
"/_api/album/$id",
|
"/_api/album/$id",
|
||||||
@@ -665,6 +633,7 @@ export const routeTree = rootRoute
|
|||||||
"/_api/boxset/$id",
|
"/_api/boxset/$id",
|
||||||
"/_api/episode/$id",
|
"/_api/episode/$id",
|
||||||
"/_api/item/$id",
|
"/_api/item/$id",
|
||||||
|
"/_api/library/$id",
|
||||||
"/_api/person/$id",
|
"/_api/person/$id",
|
||||||
"/_api/player/audio",
|
"/_api/player/audio",
|
||||||
"/_api/playlist/$id",
|
"/_api/playlist/$id",
|
||||||
@@ -674,13 +643,6 @@ export const routeTree = rootRoute
|
|||||||
"/_api/player/"
|
"/_api/player/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_api/library": {
|
|
||||||
"filePath": "_api/library.tsx",
|
|
||||||
"parent": "/_api",
|
|
||||||
"children": [
|
|
||||||
"/_api/library/$id"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"/_api/login": {
|
"/_api/login": {
|
||||||
"filePath": "_api/login.tsx",
|
"filePath": "_api/login.tsx",
|
||||||
"parent": "/_api",
|
"parent": "/_api",
|
||||||
@@ -722,7 +684,7 @@ export const routeTree = rootRoute
|
|||||||
},
|
},
|
||||||
"/_api/library/$id": {
|
"/_api/library/$id": {
|
||||||
"filePath": "_api/library/$id.tsx",
|
"filePath": "_api/library/$id.tsx",
|
||||||
"parent": "/_api/library"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/login/list": {
|
"/_api/login/list": {
|
||||||
"filePath": "_api/login/list.tsx",
|
"filePath": "_api/login/list.tsx",
|
||||||
|
|||||||
@@ -48,15 +48,17 @@ import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||||
import { DndProvider } from "react-dnd";
|
import { DndProvider } from "react-dnd";
|
||||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||||
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
|
||||||
type ApiContext = {
|
type ApiContext = {
|
||||||
api: Api;
|
api: Api;
|
||||||
createApi: (
|
createApi: (
|
||||||
serverAddress: string | undefined,
|
serverAddress: string | undefined | null,
|
||||||
accessToken: string | undefined,
|
accessToken: string | undefined | null,
|
||||||
) => void;
|
) => void;
|
||||||
user: UserDto | null | undefined;
|
user: UserDto | null | undefined;
|
||||||
jellyfinSDK: Jellyfin;
|
jellyfinSDK: Jellyfin;
|
||||||
|
fetchCurrentUser: (api: Api | undefined) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Route = createRootRouteWithContext<ApiContext>()({
|
export const Route = createRootRouteWithContext<ApiContext>()({
|
||||||
@@ -264,11 +266,12 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<AudioPlayer />
|
<AudioPlayer />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
<ReactQueryDevtools />
|
<ReactQueryDevtools />
|
||||||
{/* <TanStackRouterDevtools /> */}
|
<TanStackRouterDevtools />
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
errorComponent: ErrorNotice,
|
||||||
});
|
});
|
||||||
+44
-47
@@ -1,70 +1,67 @@
|
|||||||
import { getDefaultServer, getServer } from "@/utils/storage/servers";
|
import { getDefaultServer, getServer } from "@/utils/storage/servers";
|
||||||
import { getUser } from "@/utils/storage/user";
|
import { getUser } from "@/utils/storage/user";
|
||||||
import { axiosClient } from "@/utils/store/api";
|
|
||||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
import { createFileRoute, redirect, useRouter } from "@tanstack/react-router";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api")({
|
export const Route = createFileRoute("/_api")({
|
||||||
beforeLoad: async ({ context, location }) => {
|
beforeLoad: async ({ context, location }) => {
|
||||||
// console.log(context.api);
|
// console.log(context.api);
|
||||||
|
console.log(context.user);
|
||||||
if (!context.api) {
|
if (!context.api) {
|
||||||
const currentServerId = await getDefaultServer();
|
const currentServerId = await getDefaultServer();
|
||||||
if (currentServerId) {
|
if (currentServerId) {
|
||||||
const currentServer = await getServer(currentServerId);
|
const currentServer = await getServer(currentServerId);
|
||||||
const apiTemp = context.jellyfinSDK.createApi(
|
if (currentServer?.address) {
|
||||||
currentServer?.address,
|
|
||||||
null,
|
|
||||||
axiosClient,
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
await getSystemApi(apiTemp).getPingSystem();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
throw redirect({
|
|
||||||
to: "/error/$code",
|
|
||||||
params: {
|
|
||||||
code: "101",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const userOnDisk = await getUser();
|
|
||||||
if (userOnDisk) {
|
|
||||||
if (location.pathname !== "/login/manual") {
|
|
||||||
const apiTemp = context.jellyfinSDK.createApi(
|
|
||||||
currentServer?.address,
|
|
||||||
userOnDisk.AccessToken,
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
await getUserApi(apiTemp).getCurrentUser();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
throw redirect({
|
|
||||||
to: "/login/manual",
|
|
||||||
search: {
|
|
||||||
redirect: location.href,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// return { api: apiTemp };
|
|
||||||
}
|
|
||||||
context.createApi(currentServer?.address, userOnDisk.AccessToken);
|
|
||||||
} else {
|
|
||||||
const apiTemp = context.jellyfinSDK.createApi(
|
const apiTemp = context.jellyfinSDK.createApi(
|
||||||
currentServer?.address,
|
currentServer?.address,
|
||||||
null,
|
undefined,
|
||||||
);
|
);
|
||||||
context.createApi(currentServer?.address, undefined); // Creates Api
|
try {
|
||||||
// return { api: apiTemp };
|
await getSystemApi(apiTemp).getPingSystem();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
throw redirect({
|
||||||
|
to: "/error/$code",
|
||||||
|
params: {
|
||||||
|
code: "101",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const userOnDisk = await getUser();
|
||||||
|
if (userOnDisk) {
|
||||||
|
if (location.pathname !== "/login/manual") {
|
||||||
|
const apiTemp = context.jellyfinSDK.createApi(
|
||||||
|
currentServer?.address,
|
||||||
|
userOnDisk.AccessToken,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const user = await getUserApi(apiTemp).getCurrentUser();
|
||||||
|
// return { user: user.data };
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
throw redirect({
|
||||||
|
to: "/login/manual",
|
||||||
|
search: {
|
||||||
|
redirect: location.href,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.createApi(currentServer?.address, userOnDisk.AccessToken);
|
||||||
|
} else {
|
||||||
|
context.jellyfinSDK.createApi(currentServer?.address, undefined);
|
||||||
|
context.createApi(currentServer?.address, undefined); // Creates Api
|
||||||
|
|
||||||
|
// return { api: apiTemp };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (context.api) {
|
} else if (context.api) {
|
||||||
if (context.api.accessToken && location.pathname !== "/login/manual") {
|
if (context.api.accessToken && location.pathname !== "/login/manual") {
|
||||||
try {
|
try {
|
||||||
return {
|
await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate
|
||||||
user: await getUserApi(context.api).getCurrentUser(),
|
|
||||||
}; // Verify user is able to authenticate
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
throw redirect({
|
throw redirect({
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import "./album.scss";
|
|||||||
import TagChip from "@/components/tagChip";
|
import TagChip from "@/components/tagChip";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
import lyricsIcon from "../../../assets/icons/lyrics.svg";
|
import lyricsIcon from "../../../assets/icons/lyrics.svg";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -91,26 +92,18 @@ function MusicAlbumTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -119,7 +112,7 @@ function MusicAlbumTitlePage() {
|
|||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
const result = await getLibraryApi(api).getSimilarAlbums({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data?.Id,
|
itemId: item.data?.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
});
|
});
|
||||||
@@ -134,7 +127,7 @@ function MusicAlbumTitlePage() {
|
|||||||
queryKey: ["item", "musicTracks", id],
|
queryKey: ["item", "musicTracks", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data?.Id,
|
parentId: item.data?.Id,
|
||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
sortBy: ["IndexNumber"],
|
sortBy: ["IndexNumber"],
|
||||||
@@ -170,7 +163,7 @@ function MusicAlbumTitlePage() {
|
|||||||
) => {
|
) => {
|
||||||
const url = generateAudioStreamUrl(
|
const url = generateAudioStreamUrl(
|
||||||
item.Id,
|
item.Id,
|
||||||
user.data?.Id,
|
user?.Id,
|
||||||
api.deviceInfo.id,
|
api.deviceInfo.id,
|
||||||
api.basePath,
|
api.basePath,
|
||||||
);
|
);
|
||||||
@@ -235,13 +228,13 @@ function MusicAlbumTitlePage() {
|
|||||||
item={item}
|
item={item}
|
||||||
audio
|
audio
|
||||||
itemType={item.data.Type}
|
itemType={item.data.Type}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
isFavorite={item.data.UserData?.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
queryKey={["item", "musicTracks"]}
|
queryKey={["item", "musicTracks"]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -295,7 +288,7 @@ function MusicAlbumTitlePage() {
|
|||||||
itemId={track.Id}
|
itemId={track.Id}
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
queryKey={["item", "musicTracks"]}
|
queryKey={["item", "musicTracks"]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
itemName={track.Name}
|
itemName={track.Name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -352,13 +345,13 @@ function MusicAlbumTitlePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{similarItems.data.TotalRecordCount > 0 && (
|
{(similarItems.data.TotalRecordCount ?? -1) > 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="You might also like"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={7}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
{similarItems.data.Items.map((similar) => {
|
{similarItems.data.Items?.map((similar) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={similar.Id}
|
key={similar.Id}
|
||||||
@@ -390,13 +383,7 @@ function MusicAlbumTitlePage() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import "./artist.scss";
|
|||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -69,26 +70,19 @@ function ArtistTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
fields: [ItemFields.Crew],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -102,7 +96,7 @@ function ArtistTitlePage() {
|
|||||||
sortOrder: [SortOrder.Descending],
|
sortOrder: [SortOrder.Descending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
includeItemTypes: [BaseItemKind.MusicAlbum],
|
includeItemTypes: [BaseItemKind.MusicAlbum],
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
fields: [ItemFields.Overview],
|
fields: [ItemFields.Overview],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -119,7 +113,7 @@ function ArtistTitlePage() {
|
|||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
fields: [ItemFields.Overview],
|
fields: [ItemFields.Overview],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -137,7 +131,7 @@ function ArtistTitlePage() {
|
|||||||
sortOrder: [SortOrder.Descending],
|
sortOrder: [SortOrder.Descending],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
includeItemTypes: [BaseItemKind.MusicAlbum],
|
includeItemTypes: [BaseItemKind.MusicAlbum],
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -295,8 +289,8 @@ function ArtistTitlePage() {
|
|||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -314,7 +308,7 @@ function ArtistTitlePage() {
|
|||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.data.ExternalUrls.map((url) => (
|
{item.data.ExternalUrls?.map((url) => (
|
||||||
<IconLink url={url.Url} name={url.Name} />
|
<IconLink url={url.Url} name={url.Name} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -358,7 +352,7 @@ function ArtistTitlePage() {
|
|||||||
setActiveArtistTab(newVal);
|
setActiveArtistTab(newVal);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artistTabs.map((tab, index) => {
|
{artistTabs.map((tab) => {
|
||||||
return (
|
return (
|
||||||
<Tab
|
<Tab
|
||||||
key={tab.title}
|
key={tab.title}
|
||||||
@@ -391,11 +385,11 @@ function ArtistTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artistDiscography.isSuccess &&
|
{artistDiscography.isSuccess &&
|
||||||
artistDiscography.data.Items.map((tabitem) => {
|
artistDiscography.data.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<ArtistAlbum
|
<ArtistAlbum
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
user={user.data}
|
user={user}
|
||||||
album={tabitem}
|
album={tabitem}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -422,13 +416,13 @@ function ArtistTitlePage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{artistSongs.isSuccess &&
|
{artistSongs.isSuccess &&
|
||||||
artistSongs.data.Items.map((tabitem) => {
|
artistSongs.data.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<MusicTrack
|
<MusicTrack
|
||||||
item={tabitem}
|
item={tabitem}
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
queryKey={["item", id, "artist", "songs"]}
|
queryKey={["item", id, "artist", "songs"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -455,7 +449,7 @@ function ArtistTitlePage() {
|
|||||||
className="grid"
|
className="grid"
|
||||||
>
|
>
|
||||||
{artistAppearances.isSuccess &&
|
{artistAppearances.isSuccess &&
|
||||||
artistAppearances.data.Items.map((tabitem) => {
|
artistAppearances.data.Items?.map((tabitem) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={tabitem.Id}
|
key={tabitem.Id}
|
||||||
@@ -465,13 +459,7 @@ function ArtistTitlePage() {
|
|||||||
cardCaption={tabitem.AlbumArtist}
|
cardCaption={tabitem.AlbumArtist}
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["item", id, "artist", "appearences"]}
|
queryKey={["item", id, "artist", "appearences"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!tabitem.ImageBlurHashes?.Primary &&
|
|
||||||
tabitem.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(tabitem.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import "./boxset.scss";
|
|||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -72,27 +73,18 @@ function BoxSetTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -101,7 +93,7 @@ function BoxSetTitlePage() {
|
|||||||
queryKey: ["item", id, "collection"],
|
queryKey: ["item", id, "collection"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data.Id,
|
parentId: item.data.Id,
|
||||||
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
||||||
excludeLocationTypes: [LocationType.Virtual],
|
excludeLocationTypes: [LocationType.Virtual],
|
||||||
@@ -117,8 +109,8 @@ function BoxSetTitlePage() {
|
|||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getLibraryApi(api).getSimilarItems({
|
const result = await getLibraryApi(api).getSimilarItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data?.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -370,7 +362,7 @@ function BoxSetTitlePage() {
|
|||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack={0}
|
currentSubTrack={0}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
fullWidth: true,
|
fullWidth: true,
|
||||||
}}
|
}}
|
||||||
@@ -382,14 +374,14 @@ function BoxSetTitlePage() {
|
|||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData.Played}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -437,7 +429,7 @@ function BoxSetTitlePage() {
|
|||||||
cardCaption={similar.ProductionYear}
|
cardCaption={similar.ProductionYear}
|
||||||
cardType={"portrait"}
|
cardType={"portrait"}
|
||||||
queryKey={["item", id, "collection"]}
|
queryKey={["item", id, "collection"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
!!similar.ImageBlurHashes?.Primary &&
|
||||||
similar.ImageBlurHashes?.Primary[
|
similar.ImageBlurHashes?.Primary[
|
||||||
@@ -487,7 +479,7 @@ function BoxSetTitlePage() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
!!similar.ImageBlurHashes?.Primary &&
|
||||||
similar.ImageBlurHashes?.Primary[
|
similar.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
|||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -97,27 +98,19 @@ function EpisodeTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
fields: [ItemFields.Crew],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -126,9 +119,9 @@ function EpisodeTitlePage() {
|
|||||||
queryKey: ["item", id, "episode", "upcomingEpisodes"],
|
queryKey: ["item", id, "episode", "upcomingEpisodes"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
parentId: item.data.ParentId,
|
parentId: item.data?.ParentId ?? "",
|
||||||
startIndex: item.data.IndexNumber,
|
startIndex: item.data?.IndexNumber ?? 0,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -688,7 +681,7 @@ function EpisodeTitlePage() {
|
|||||||
currentVideoTrack={selectedVideoTrack}
|
currentVideoTrack={selectedVideoTrack}
|
||||||
currentAudioTrack={selectedAudioTrack}
|
currentAudioTrack={selectedAudioTrack}
|
||||||
currentSubTrack={selectedSubtitleTrack}
|
currentSubTrack={selectedSubtitleTrack}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row" style={{ gap: "1em" }}>
|
<div className="flex flex-row" style={{ gap: "1em" }}>
|
||||||
@@ -701,14 +694,14 @@ function EpisodeTitlePage() {
|
|||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData.Played}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -812,7 +805,7 @@ function EpisodeTitlePage() {
|
|||||||
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
queryKey={["item", id, "episode", "upcomingEpisodes"]}
|
queryKey={["item", id, "episode", "upcomingEpisodes"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!episode.ImageBlurHashes?.Primary &&
|
!!episode.ImageBlurHashes?.Primary &&
|
||||||
episode.ImageBlurHashes?.Primary[
|
episode.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ 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,
|
||||||
@@ -21,21 +22,13 @@ function FavoritePage() {
|
|||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const movies = useQuery({
|
const movies = useQuery({
|
||||||
queryKey: ["favorite", "movies"],
|
queryKey: ["favorite", "movies"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.Movie],
|
includeItemTypes: [BaseItemKind.Movie],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -48,7 +41,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "series"],
|
queryKey: ["favorite", "series"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.Series],
|
includeItemTypes: [BaseItemKind.Series],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -61,7 +54,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "musicAlbum"],
|
queryKey: ["favorite", "musicAlbum"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.MusicAlbum],
|
includeItemTypes: [BaseItemKind.MusicAlbum],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -74,7 +67,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "audio"],
|
queryKey: ["favorite", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -87,7 +80,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "book"],
|
queryKey: ["favorite", "book"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.Book],
|
includeItemTypes: [BaseItemKind.Book],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -100,7 +93,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "musicArtist"],
|
queryKey: ["favorite", "musicArtist"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.MusicArtist],
|
includeItemTypes: [BaseItemKind.MusicArtist],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -113,7 +106,7 @@ function FavoritePage() {
|
|||||||
queryKey: ["favorite", "person"],
|
queryKey: ["favorite", "person"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
isFavorite: true,
|
isFavorite: true,
|
||||||
includeItemTypes: [BaseItemKind.Person],
|
includeItemTypes: [BaseItemKind.Person],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -148,7 +141,7 @@ function FavoritePage() {
|
|||||||
cardCaption={item.ProductionYear}
|
cardCaption={item.ProductionYear}
|
||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["favorite", "movies"]}
|
queryKey={["favorite", "movies"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -176,7 +169,7 @@ function FavoritePage() {
|
|||||||
}`}
|
}`}
|
||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["favorite", "series"]}
|
queryKey={["favorite", "series"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -198,7 +191,7 @@ function FavoritePage() {
|
|||||||
cardCaption={item.ProductionYear}
|
cardCaption={item.ProductionYear}
|
||||||
cardType="square"
|
cardType="square"
|
||||||
queryKey={["favorite", "audio"]}
|
queryKey={["favorite", "audio"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -221,7 +214,7 @@ function FavoritePage() {
|
|||||||
cardCaption={item.AlbumArtist}
|
cardCaption={item.AlbumArtist}
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["favorite", "musicAlbum"]}
|
queryKey={["favorite", "musicAlbum"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -244,7 +237,7 @@ function FavoritePage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"portrait"}
|
cardType={"portrait"}
|
||||||
queryKey={["favorite", "book"]}
|
queryKey={["favorite", "book"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -266,7 +259,7 @@ function FavoritePage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["favorite", "musicArtist"]}
|
queryKey={["favorite", "musicArtist"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -288,7 +281,7 @@ function FavoritePage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["favorite", "person"]}
|
queryKey={["favorite", "person"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -19,11 +19,10 @@ import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
|
|
||||||
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
import { setBackdrop } from "@/utils/store/backdrop";
|
import { setBackdrop } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import CarouselSlide from "@/components/carouselSlide";
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
@@ -33,36 +32,25 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/home/")({
|
export const Route = createFileRoute("/_api/home/")({
|
||||||
component: Home,
|
component: Home,
|
||||||
onError: (err) => {
|
|
||||||
console.log(err);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
console.log(usr.data);
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data && !!api.accessToken,
|
enabled: !!user?.Id && !!api.accessToken,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +58,7 @@ function Home() {
|
|||||||
queryKey: ["home", "latestMedia"],
|
queryKey: ["home", "latestMedia"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.Overview,
|
ItemFields.Overview,
|
||||||
ItemFields.ParentId,
|
ItemFields.ParentId,
|
||||||
@@ -84,14 +72,14 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return media.data;
|
return media.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const resumeItemsVideo = useQuery({
|
const resumeItemsVideo = useQuery({
|
||||||
queryKey: ["home", "resume", "video"],
|
queryKey: ["home", "resume", "video"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
mediaTypes: ["Video"],
|
mediaTypes: ["Video"],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
@@ -99,7 +87,7 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return resumeItems.data;
|
return resumeItems.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
refetchOnMount: true,
|
refetchOnMount: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,7 +95,7 @@ function Home() {
|
|||||||
queryKey: ["home", "resume", "audio"],
|
queryKey: ["home", "resume", "audio"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const resumeItems = await getItemsApi(api).getResumeItems({
|
const resumeItems = await getItemsApi(api).getResumeItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
mediaTypes: ["Audio"],
|
mediaTypes: ["Audio"],
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
@@ -115,14 +103,14 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return resumeItems.data;
|
return resumeItems.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const upNextItems = useQuery({
|
const upNextItems = useQuery({
|
||||||
queryKey: ["home", "upNext"],
|
queryKey: ["home", "upNext"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const upNext = await getTvShowsApi(api).getNextUp({
|
const upNext = await getTvShowsApi(api).getNextUp({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.PrimaryImageAspectRatio,
|
ItemFields.PrimaryImageAspectRatio,
|
||||||
ItemFields.MediaStreams,
|
ItemFields.MediaStreams,
|
||||||
@@ -133,7 +121,7 @@ function Home() {
|
|||||||
});
|
});
|
||||||
return upNext.data;
|
return upNext.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
refetchOnMount: true,
|
refetchOnMount: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -234,12 +222,14 @@ function Home() {
|
|||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
disableOverlay
|
disableOverlay
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
navigate({
|
if (item.Id) {
|
||||||
to: "/library/$id",
|
navigate({
|
||||||
params: { id: item.Id ?? "" },
|
to: "/library/$id",
|
||||||
})
|
params: { id: item.Id },
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
overrideIcon={item.CollectionType}
|
overrideIcon={item.CollectionType}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -296,7 +286,7 @@ function Home() {
|
|||||||
}
|
}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
queryKey={["home", "upNext"]}
|
queryKey={["home", "upNext"]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -349,7 +339,7 @@ function Home() {
|
|||||||
}
|
}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
queryKey={["home", "resume", "video"]}
|
queryKey={["home", "resume", "video"]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -380,7 +370,7 @@ function Home() {
|
|||||||
cardCaption={item.ProductionYear}
|
cardCaption={item.ProductionYear}
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
queryKey={["home", "resume", "audio"]}
|
queryKey={["home", "resume", "audio"]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
|||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { queryClient } from "@/main";
|
import { queryClient } from "@/main";
|
||||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -102,26 +103,18 @@ function ItemDetail() {
|
|||||||
|
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -134,28 +127,28 @@ function ItemDetail() {
|
|||||||
let result;
|
let result;
|
||||||
if (item.data.Type === "Movie") {
|
if (item.data.Type === "Movie") {
|
||||||
result = await getLibraryApi(api).getSimilarMovies({
|
result = await getLibraryApi(api).getSimilarMovies({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
});
|
});
|
||||||
} else if (item.data.Type === "Series") {
|
} else if (item.data.Type === "Series") {
|
||||||
result = await getLibraryApi(api).getSimilarShows({
|
result = await getLibraryApi(api).getSimilarShows({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
});
|
});
|
||||||
} else if (item.data.Type === "MusicAlbum") {
|
} else if (item.data.Type === "MusicAlbum") {
|
||||||
result = await getLibraryApi(api).getSimilarAlbums({
|
result = await getLibraryApi(api).getSimilarAlbums({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
});
|
});
|
||||||
} else if (item.data.Type === "MusicArtist") {
|
} else if (item.data.Type === "MusicArtist") {
|
||||||
result = await getLibraryApi(api).getSimilarArtists({
|
result = await getLibraryApi(api).getSimilarArtists({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
result = await getLibraryApi(api).getSimilarItems({
|
result = await getLibraryApi(api).getSimilarItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -193,8 +186,6 @@ function ItemDetail() {
|
|||||||
const [selectedAudioTrack, setSelectedAudioTrack] = useState(null);
|
const [selectedAudioTrack, setSelectedAudioTrack] = useState(null);
|
||||||
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(null);
|
const [selectedSubtitleTrack, setSelectedSubtitleTrack] = useState(null);
|
||||||
|
|
||||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
|
||||||
|
|
||||||
const [directors, setDirectors] = useState([]);
|
const [directors, setDirectors] = useState([]);
|
||||||
const [writers, setWriters] = useState([]);
|
const [writers, setWriters] = useState([]);
|
||||||
const [actors, setActors] = useState([]);
|
const [actors, setActors] = useState([]);
|
||||||
@@ -694,7 +685,7 @@ function ItemDetail() {
|
|||||||
currentVideoTrack={selectedVideoTrack}
|
currentVideoTrack={selectedVideoTrack}
|
||||||
currentAudioTrack={selectedAudioTrack}
|
currentAudioTrack={selectedAudioTrack}
|
||||||
currentSubTrack={selectedSubtitleTrack}
|
currentSubTrack={selectedSubtitleTrack}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
fullWidth: true,
|
fullWidth: true,
|
||||||
}}
|
}}
|
||||||
@@ -710,14 +701,14 @@ function ItemDetail() {
|
|||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData.Played}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1043,7 +1034,7 @@ function ItemDetail() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
!!similar.ImageBlurHashes?.Primary &&
|
||||||
similar.ImageBlurHashes?.Primary[
|
similar.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
import type {
|
|
||||||
BaseItemKind,
|
|
||||||
ItemSortBy,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
type LibraryParamType = {
|
|
||||||
currentViewType: BaseItemKind;
|
|
||||||
sortAscending: boolean;
|
|
||||||
sortBy: ItemSortBy;
|
|
||||||
filters: {
|
|
||||||
isPlayed: boolean;
|
|
||||||
isUnPlayed: boolean;
|
|
||||||
isResumable: boolean;
|
|
||||||
isFavorite: boolean;
|
|
||||||
isLiked: boolean;
|
|
||||||
isUnliked: boolean;
|
|
||||||
hasSubtitles: boolean;
|
|
||||||
hasTrailer: boolean;
|
|
||||||
hasSpecialFeature: boolean;
|
|
||||||
hasThemeSong: boolean;
|
|
||||||
hasThemeVideo: boolean;
|
|
||||||
isBluRay: boolean;
|
|
||||||
isDVD: boolean;
|
|
||||||
isHD: undefined | boolean;
|
|
||||||
isSD: boolean;
|
|
||||||
is4K: boolean;
|
|
||||||
is3D: boolean;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/library")({
|
|
||||||
validateSearch: (search: Record<string, any>): LibraryParamType => {
|
|
||||||
return {
|
|
||||||
currentViewType: search.viewType,
|
|
||||||
sortAscending: search.sortAscending,
|
|
||||||
sortBy: search.sortBy,
|
|
||||||
filters: search.filters,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -51,6 +51,8 @@ import type { AxiosResponse } from "axios";
|
|||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
import LibraryItemsSkeleton from "@/components/skeleton/libraryItems";
|
import LibraryItemsSkeleton from "@/components/skeleton/libraryItems";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
type SortByObject = { title: string; value: ItemSortBy };
|
type SortByObject = { title: string; value: ItemSortBy };
|
||||||
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
||||||
@@ -80,29 +82,22 @@ export const Route = createFileRoute("/_api/library/$id")({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function LibraryView() {
|
function LibraryView() {
|
||||||
const api = Route.useRouteContext().api;
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentLib = useQuery({
|
const currentLib = useQuery({
|
||||||
queryKey: ["libraryView", "currentLib", id],
|
queryKey: ["libraryView", "currentLib", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
});
|
});
|
||||||
@@ -431,7 +426,11 @@ function LibraryView() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// And they say typescript makes your code better :|
|
// And they say typescript makes your code better :|
|
||||||
const cachedVal = JSON.parse(sessionStorage.getItem(`library-${currentLib.data?.Id}-config_sort`) as string);
|
const cachedVal = JSON.parse(
|
||||||
|
sessionStorage.getItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_sort`,
|
||||||
|
) as string,
|
||||||
|
);
|
||||||
// as {
|
// as {
|
||||||
// sortAscending: boolean;
|
// sortAscending: boolean;
|
||||||
// sortBy: ItemSortBy;
|
// sortBy: ItemSortBy;
|
||||||
@@ -448,13 +447,9 @@ function LibraryView() {
|
|||||||
() => {
|
() => {
|
||||||
const cachedVal = sessionStorage.getItem(
|
const cachedVal = sessionStorage.getItem(
|
||||||
`library-${currentLib.data?.Id}-config_fliters`,
|
`library-${currentLib.data?.Id}-config_fliters`,
|
||||||
);
|
);
|
||||||
if (
|
if (cachedVal !== null) {
|
||||||
cachedVal !== null
|
return JSON.parse(cachedVal);
|
||||||
) {
|
|
||||||
return JSON.parse(
|
|
||||||
cachedVal
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isPlayed: false,
|
isPlayed: false,
|
||||||
@@ -501,32 +496,32 @@ function LibraryView() {
|
|||||||
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
if (currentViewType === "MusicArtist") {
|
if (currentViewType === "MusicArtist") {
|
||||||
result = await getArtistsApi(api).getAlbumArtists({
|
result = await getArtistsApi(api).getAlbumArtists({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: id,
|
parentId: id,
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Artist") {
|
} else if (currentViewType === "Artist") {
|
||||||
result = await getArtistsApi(api).getArtists({
|
result = await getArtistsApi(api).getArtists({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: id,
|
parentId: id,
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Person") {
|
} else if (currentViewType === "Person") {
|
||||||
result = await getPersonsApi(api).getPersons({
|
result = await getPersonsApi(api).getPersons({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
personTypes: ["Actor"],
|
personTypes: ["Actor"],
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Genre") {
|
} else if (currentViewType === "Genre") {
|
||||||
result = await getGenresApi(api).getGenres({
|
result = await getGenresApi(api).getGenres({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: id,
|
parentId: id,
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "MusicGenre") {
|
} else if (currentViewType === "MusicGenre") {
|
||||||
result = await getMusicGenresApi(api).getMusicGenres({
|
result = await getMusicGenresApi(api).getMusicGenres({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: id,
|
parentId: id,
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Studio") {
|
} else if (currentViewType === "Studio") {
|
||||||
result = await getStudiosApi(api).getStudios({
|
result = await getStudiosApi(api).getStudios({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: id,
|
parentId: id,
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "BoxSet") {
|
} else if (currentViewType === "BoxSet") {
|
||||||
@@ -543,7 +538,7 @@ function LibraryView() {
|
|||||||
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
||||||
|
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: currentLib.data?.Id,
|
parentId: currentLib.data?.Id,
|
||||||
recursive:
|
recursive:
|
||||||
currentLib.data?.CollectionType === "boxsets" ? undefined : true,
|
currentLib.data?.CollectionType === "boxsets" ? undefined : true,
|
||||||
@@ -578,7 +573,7 @@ function LibraryView() {
|
|||||||
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
||||||
|
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
parentId: currentLib.data?.Id,
|
parentId: currentLib.data?.Id,
|
||||||
recursive:
|
recursive:
|
||||||
currentLib.data?.CollectionType === "boxsets" ? undefined : true,
|
currentLib.data?.CollectionType === "boxsets" ? undefined : true,
|
||||||
@@ -603,7 +598,7 @@ function LibraryView() {
|
|||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
// enabled: false,
|
// enabled: false,
|
||||||
enabled: user.isSuccess && Boolean(currentViewType) && currentLib.isSuccess,
|
enabled: user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
// gcTime: 0,
|
// gcTime: 0,
|
||||||
});
|
});
|
||||||
@@ -1172,7 +1167,7 @@ function LibraryView() {
|
|||||||
libraryId={currentLib.data.Id}
|
libraryId={currentLib.data.Id}
|
||||||
genreId={item.Id}
|
genreId={item.Id}
|
||||||
genreName={item.Name}
|
genreName={item.Name}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@@ -1243,7 +1238,7 @@ function LibraryView() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
// queryKey={items}
|
// queryKey={items}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>,
|
</div>,
|
||||||
);
|
);
|
||||||
@@ -1314,7 +1309,7 @@ function LibraryView() {
|
|||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// ]}
|
// ]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -1333,4 +1328,3 @@ function LibraryView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default LibraryView;
|
export default LibraryView;
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ import "./person.scss";
|
|||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -74,27 +75,18 @@ function PersonTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -103,7 +95,7 @@ function PersonTitlePage() {
|
|||||||
queryKey: ["item", id, "personMovies"],
|
queryKey: ["item", id, "personMovies"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
includeItemTypes: [BaseItemKind.Movie],
|
includeItemTypes: [BaseItemKind.Movie],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -120,7 +112,7 @@ function PersonTitlePage() {
|
|||||||
queryKey: ["item", id, "personShows"],
|
queryKey: ["item", id, "personShows"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
includeItemTypes: [BaseItemKind.Series],
|
includeItemTypes: [BaseItemKind.Series],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -138,7 +130,7 @@ function PersonTitlePage() {
|
|||||||
queryKey: ["item", id, "personBooks"],
|
queryKey: ["item", id, "personBooks"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
includeItemTypes: [BaseItemKind.Book],
|
includeItemTypes: [BaseItemKind.Book],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -155,7 +147,7 @@ function PersonTitlePage() {
|
|||||||
queryKey: ["item", id, "personPhotos"],
|
queryKey: ["item", id, "personPhotos"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
includeItemTypes: [BaseItemKind.Photo],
|
includeItemTypes: [BaseItemKind.Photo],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -171,7 +163,7 @@ function PersonTitlePage() {
|
|||||||
queryKey: ["item", id, "personEpisodes"],
|
queryKey: ["item", id, "personEpisodes"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
personIds: [id],
|
personIds: [id],
|
||||||
includeItemTypes: [BaseItemKind.Episode],
|
includeItemTypes: [BaseItemKind.Episode],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -343,7 +335,7 @@ function PersonTitlePage() {
|
|||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -480,7 +472,7 @@ function PersonTitlePage() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={tab.queryKey}
|
queryKey={tab.queryKey}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!tabitem.ImageBlurHashes?.Primary &&
|
!!tabitem.ImageBlurHashes?.Primary &&
|
||||||
tabitem.ImageBlurHashes?.Primary[
|
tabitem.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import ReactPlayer from "react-player";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
changeSubtitleTrack,
|
changeSubtitleTrack,
|
||||||
|
playItemFromQueue,
|
||||||
toggleSubtitleTrack,
|
toggleSubtitleTrack,
|
||||||
usePlaybackStore,
|
usePlaybackStore,
|
||||||
} from "@/utils/store/playback";
|
} from "@/utils/store/playback";
|
||||||
@@ -47,11 +48,14 @@ import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
|||||||
import QueueButton from "@/components/buttons/queueButton";
|
import QueueButton from "@/components/buttons/queueButton";
|
||||||
import OutroCard from "@/components/outroCard";
|
import OutroCard from "@/components/outroCard";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue, { clearQueue } from "@/utils/store/queue";
|
||||||
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
||||||
import { toNumber } from "lodash";
|
import { toNumber } from "lodash";
|
||||||
import type { OnProgressProps } from "react-player/base";
|
import type { OnProgressProps } from "react-player/base";
|
||||||
import type { TrackProps } from "react-player/file";
|
import type { TrackProps } from "react-player/file";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
const ticksDisplay = (ticks: number) => {
|
const ticksDisplay = (ticks: number) => {
|
||||||
const time = Math.round(ticks / 10000);
|
const time = Math.round(ticks / 10000);
|
||||||
@@ -87,6 +91,8 @@ function VideoPlayer() {
|
|||||||
const [hoveringOsd, setHoveringOsd] = useState(false);
|
const [hoveringOsd, setHoveringOsd] = useState(false);
|
||||||
const player = useRef<ReactPlayer | null>(null);
|
const player = useRef<ReactPlayer | null>(null);
|
||||||
|
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
playbackStream,
|
playbackStream,
|
||||||
item,
|
item,
|
||||||
@@ -195,6 +201,7 @@ function VideoPlayer() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
||||||
|
clearQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleShowOsd = () => {
|
const handleShowOsd = () => {
|
||||||
@@ -522,6 +529,15 @@ function VideoPlayer() {
|
|||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [volume]);
|
}, [volume]);
|
||||||
|
|
||||||
|
const handlePlaybackEnded = () => {
|
||||||
|
//check if next track item exists
|
||||||
|
if (queue[currentQueueItemIndex + 1].Id) {
|
||||||
|
playItemFromQueue("next", user?.Id, api);
|
||||||
|
} else {
|
||||||
|
handleExitPlayer(); // Exit player if playback has finished and the queue is empty
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="video-player">
|
<div className="video-player">
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
@@ -877,6 +893,7 @@ function VideoPlayer() {
|
|||||||
console.error(hls);
|
console.error(hls);
|
||||||
console.error(hlsG);
|
console.error(hlsG);
|
||||||
}}
|
}}
|
||||||
|
onEnded={handlePlaybackEnded}
|
||||||
width="100vw"
|
width="100vw"
|
||||||
height="100vh"
|
height="100vh"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ 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 { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
|
|
||||||
@@ -58,27 +59,18 @@ function PlaylistTitlePage() {
|
|||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -87,7 +79,7 @@ function PlaylistTitlePage() {
|
|||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
const result = await getLibraryApi(api).getSimilarAlbums({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
});
|
});
|
||||||
@@ -102,7 +94,7 @@ function PlaylistTitlePage() {
|
|||||||
queryKey: ["item", id, "musicTracks"],
|
queryKey: ["item", id, "musicTracks"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getPlaylistsApi(api).getPlaylistItems({
|
const result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
playlistId: item.data.Id,
|
playlistId: item.data.Id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -161,7 +153,7 @@ function PlaylistTitlePage() {
|
|||||||
item={track}
|
item={track}
|
||||||
key={track.Id}
|
key={track.Id}
|
||||||
queryKey={["item", id, "musicTracks"]}
|
queryKey={["item", id, "musicTracks"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
playlistItem
|
playlistItem
|
||||||
playlistItemId={item.data.Id}
|
playlistItemId={item.data.Id}
|
||||||
trackIndex={index}
|
trackIndex={index}
|
||||||
@@ -208,7 +200,7 @@ function PlaylistTitlePage() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
!!similar.ImageBlurHashes?.Primary &&
|
||||||
similar.ImageBlurHashes?.Primary[
|
similar.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
|||||||
import "./search.scss";
|
import "./search.scss";
|
||||||
import { Dialog, Fab } from "@mui/material";
|
import { Dialog, Fab } from "@mui/material";
|
||||||
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/search/")({
|
export const Route = createFileRoute("/_api/search/")({
|
||||||
component: SearchPage,
|
component: SearchPage,
|
||||||
@@ -37,15 +38,7 @@ function SearchPage() {
|
|||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
// const searchParam = useDebounce(query, 500);
|
// const searchParam = useDebounce(query, 500);
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const itemLimit = 12;
|
const itemLimit = 12;
|
||||||
|
|
||||||
@@ -53,7 +46,7 @@ function SearchPage() {
|
|||||||
queryKey: ["search", "items", "Movie", query],
|
queryKey: ["search", "items", "Movie", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.Movie],
|
includeItemTypes: [BaseItemKind.Movie],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -61,13 +54,13 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const series = useQuery({
|
const series = useQuery({
|
||||||
queryKey: ["search", "items", "Series", query],
|
queryKey: ["search", "items", "Series", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.Series],
|
includeItemTypes: [BaseItemKind.Series],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -75,13 +68,13 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const musicAlbum = useQuery({
|
const musicAlbum = useQuery({
|
||||||
queryKey: ["search", "items", "MusicAlbum", query],
|
queryKey: ["search", "items", "MusicAlbum", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.MusicAlbum],
|
includeItemTypes: [BaseItemKind.MusicAlbum],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -89,13 +82,13 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const audio = useQuery({
|
const audio = useQuery({
|
||||||
queryKey: ["search", "items", "Audio", query],
|
queryKey: ["search", "items", "Audio", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -103,13 +96,13 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const book = useQuery({
|
const book = useQuery({
|
||||||
queryKey: ["search", "items", "Book", query],
|
queryKey: ["search", "items", "Book", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.Book],
|
includeItemTypes: [BaseItemKind.Book],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -117,13 +110,13 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const musicArtists = useQuery({
|
const musicArtists = useQuery({
|
||||||
queryKey: ["search", "items", "MusicArtists", query],
|
queryKey: ["search", "items", "MusicArtists", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
includeItemTypes: [BaseItemKind.MusicArtist],
|
includeItemTypes: [BaseItemKind.MusicArtist],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -131,32 +124,32 @@ function SearchPage() {
|
|||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const person = useQuery({
|
const person = useQuery({
|
||||||
queryKey: ["search", "items", "Person", query],
|
queryKey: ["search", "items", "Person", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getPersonsApi(api).getPersons({
|
const result = await getPersonsApi(api).getPersons({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
limit: itemLimit,
|
limit: itemLimit,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
const episodes = useQuery({
|
const episodes = useQuery({
|
||||||
queryKey: ["search", "items", "Episodes", query],
|
queryKey: ["search", "items", "Episodes", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getSearchApi(api).getSearchHints({
|
const result = await getSearchApi(api).getSearchHints({
|
||||||
userId: user.data?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
limit: itemLimit,
|
limit: itemLimit,
|
||||||
includeItemTypes: ["Episode"],
|
includeItemTypes: ["Episode"],
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: user.isSuccess,
|
enabled: !!user?.Id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
@@ -224,7 +217,7 @@ function SearchPage() {
|
|||||||
cardCaption={item.ProductionYear}
|
cardCaption={item.ProductionYear}
|
||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["search", "items", "Movie", query]}
|
queryKey={["search", "items", "Movie", query]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -252,7 +245,7 @@ function SearchPage() {
|
|||||||
}`}
|
}`}
|
||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["search", "items", "Series", query]}
|
queryKey={["search", "items", "Series", query]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
!!item.ImageBlurHashes?.Primary &&
|
||||||
item.ImageBlurHashes?.Primary[
|
item.ImageBlurHashes?.Primary[
|
||||||
@@ -273,7 +266,7 @@ function SearchPage() {
|
|||||||
cardTitle={episode.Series}
|
cardTitle={episode.Series}
|
||||||
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.data.Id}
|
userId={user?.Id}
|
||||||
disableRunTime
|
disableRunTime
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -291,7 +284,7 @@ function SearchPage() {
|
|||||||
cardCaption={item.ProductionYear}
|
cardCaption={item.ProductionYear}
|
||||||
cardType="square"
|
cardType="square"
|
||||||
queryKey={["search", "items", "Audio", query]}
|
queryKey={["search", "items", "Audio", query]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
@@ -308,7 +301,7 @@ function SearchPage() {
|
|||||||
cardCaption={item.AlbumArtist}
|
cardCaption={item.AlbumArtist}
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["search", "items", "MusicAlbum", query]}
|
queryKey={["search", "items", "MusicAlbum", query]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
@@ -325,7 +318,7 @@ function SearchPage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"portrait"}
|
cardType={"portrait"}
|
||||||
queryKey={["search", "items", "Book", query]}
|
queryKey={["search", "items", "Book", query]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
@@ -341,7 +334,7 @@ function SearchPage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["search", "items", "MusicArtists", query]}
|
queryKey={["search", "items", "MusicArtists", query]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
@@ -357,7 +350,7 @@ function SearchPage() {
|
|||||||
disableOverlay
|
disableOverlay
|
||||||
cardType={"square"}
|
cardType={"square"}
|
||||||
queryKey={["search", "items", "Person", query]}
|
queryKey={["search", "items", "Person", query]}
|
||||||
userId={user.data?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import IconLink from "@/components/iconLink";
|
|||||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
@@ -101,27 +102,18 @@ function SeriesTitlePage() {
|
|||||||
|
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const usr = await getUserApi(api).getCurrentUser();
|
|
||||||
return usr.data;
|
|
||||||
},
|
|
||||||
networkMode: "always",
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
queryKey: ["item", id],
|
queryKey: ["item", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
fields: [ItemFields.Crew],
|
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
enabled: !!user.data,
|
enabled: !!user?.Id,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
});
|
});
|
||||||
@@ -130,7 +122,7 @@ function SeriesTitlePage() {
|
|||||||
queryKey: ["item", id, "similarItem"],
|
queryKey: ["item", id, "similarItem"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getLibraryApi(api).getSimilarShows({
|
const result = await getLibraryApi(api).getSimilarShows({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
});
|
});
|
||||||
@@ -145,7 +137,7 @@ function SeriesTitlePage() {
|
|||||||
queryKey: ["item", id, "seasons"],
|
queryKey: ["item", id, "seasons"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getTvShowsApi(api).getSeasons({
|
const result = await getTvShowsApi(api).getSeasons({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
seriesId: item.data.Id,
|
seriesId: item.data.Id,
|
||||||
// isSpecialSeason: false,
|
// isSpecialSeason: false,
|
||||||
});
|
});
|
||||||
@@ -160,7 +152,7 @@ function SeriesTitlePage() {
|
|||||||
queryKey: ["item", id, "nextUp"],
|
queryKey: ["item", id, "nextUp"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getTvShowsApi(api).getNextUp({
|
const result = await getTvShowsApi(api).getNextUp({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
parentId: item.data.Id,
|
parentId: item.data.Id,
|
||||||
disableFirstEpisode: true,
|
disableFirstEpisode: true,
|
||||||
@@ -189,7 +181,7 @@ function SeriesTitlePage() {
|
|||||||
queryKey: ["item", id, "season", currentSeason],
|
queryKey: ["item", id, "season", currentSeason],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
itemId: seasons.data.Items[currentSeason].Id,
|
itemId: seasons.data.Items[currentSeason].Id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -203,7 +195,7 @@ function SeriesTitlePage() {
|
|||||||
queryKey: ["item", id, "season", currentSeason, "episodes"],
|
queryKey: ["item", id, "season", currentSeason, "episodes"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getTvShowsApi(api).getEpisodes({
|
const result = await getTvShowsApi(api).getEpisodes({
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
seriesId: item.data.Id,
|
seriesId: item.data.Id,
|
||||||
seasonId: seasons.data.Items[currentSeason].Id,
|
seasonId: seasons.data.Items[currentSeason].Id,
|
||||||
fields: [ItemFields.Overview],
|
fields: [ItemFields.Overview],
|
||||||
@@ -221,7 +213,7 @@ function SeriesTitlePage() {
|
|||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserLibraryApi(api).getSpecialFeatures({
|
const result = await getUserLibraryApi(api).getSpecialFeatures({
|
||||||
itemId: item.data.Id,
|
itemId: item.data.Id,
|
||||||
userId: user.data.Id,
|
userId: user?.Id,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -594,7 +586,7 @@ function SeriesTitlePage() {
|
|||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
currentSubTrack="nosub"
|
currentSubTrack="nosub"
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
fullWidth: true,
|
fullWidth: true,
|
||||||
}}
|
}}
|
||||||
@@ -610,14 +602,14 @@ function SeriesTitlePage() {
|
|||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isFavorite={item.data.UserData.IsFavorite}
|
isFavorite={item.data.UserData.IsFavorite}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
itemId={item.data.Id}
|
itemId={item.data.Id}
|
||||||
queryKey={["item", id]}
|
queryKey={["item", id]}
|
||||||
isPlayed={item.data.UserData.Played}
|
isPlayed={item.data.UserData.Played}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -870,7 +862,7 @@ function SeriesTitlePage() {
|
|||||||
`season ${currentSeason + 1}`,
|
`season ${currentSeason + 1}`,
|
||||||
"episodes",
|
"episodes",
|
||||||
]}
|
]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -927,7 +919,7 @@ function SeriesTitlePage() {
|
|||||||
itemId={currentSeasonItem.data.Id}
|
itemId={currentSeasonItem.data.Id}
|
||||||
isFavorite={currentSeasonItem.data.UserData.IsFavorite}
|
isFavorite={currentSeasonItem.data.UserData.IsFavorite}
|
||||||
queryKey={["item", id, "season", currentSeason]}
|
queryKey={["item", id, "season", currentSeason]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
itemName={currentSeasonItem.data.Name}
|
itemName={currentSeasonItem.data.Name}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -937,7 +929,7 @@ function SeriesTitlePage() {
|
|||||||
itemId={currentSeasonItem.data.Id}
|
itemId={currentSeasonItem.data.Id}
|
||||||
isPlayed={currentSeasonItem.data.UserData.Played}
|
isPlayed={currentSeasonItem.data.UserData.Played}
|
||||||
queryKey={["item", id, "season", currentSeason]}
|
queryKey={["item", id, "season", currentSeason]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
itemName={currentSeasonItem.data.Name}
|
itemName={currentSeasonItem.data.Name}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@@ -1007,7 +999,7 @@ function SeriesTitlePage() {
|
|||||||
<Typography variant="subtitle1" textAlign="center">
|
<Typography variant="subtitle1" textAlign="center">
|
||||||
{episode.IndexNumberEnd
|
{episode.IndexNumberEnd
|
||||||
? `${episode.IndexNumber} / ${episode.IndexNumberEnd}`
|
? `${episode.IndexNumber} / ${episode.IndexNumberEnd}`
|
||||||
: episode.IndexNumber ?? 0}
|
: (episode.IndexNumber ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
@@ -1022,7 +1014,7 @@ function SeriesTitlePage() {
|
|||||||
itemId={episode.Id}
|
itemId={episode.Id}
|
||||||
itemType={BaseItemKind.Episode}
|
itemType={BaseItemKind.Episode}
|
||||||
itemUserData={episode.UserData}
|
itemUserData={episode.UserData}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
currentSubTrack="nosub"
|
currentSubTrack="nosub"
|
||||||
@@ -1112,7 +1104,7 @@ function SeriesTitlePage() {
|
|||||||
`season ${currentSeason + 1}`,
|
`season ${currentSeason + 1}`,
|
||||||
"episodes",
|
"episodes",
|
||||||
]}
|
]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemId={episode.Id}
|
itemId={episode.Id}
|
||||||
@@ -1124,7 +1116,7 @@ function SeriesTitlePage() {
|
|||||||
`season ${currentSeason + 1}`,
|
`season ${currentSeason + 1}`,
|
||||||
"episodes",
|
"episodes",
|
||||||
]}
|
]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -1157,7 +1149,7 @@ function SeriesTitlePage() {
|
|||||||
Object.keys(special.ImageBlurHashes.Primary)[0]
|
Object.keys(special.ImageBlurHashes.Primary)[0]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
onClick={() => {}}
|
onClick={() => {}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -1202,7 +1194,7 @@ function SeriesTitlePage() {
|
|||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["item", id, "similarItem"]}
|
queryKey={["item", id, "similarItem"]}
|
||||||
userId={user.data.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
imageBlurhash={
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
!!similar.ImageBlurHashes?.Primary &&
|
||||||
similar.ImageBlurHashes?.Primary[
|
similar.ImageBlurHashes?.Primary[
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { getDefaultServer } from "@/utils/storage/servers";
|
import { getDefaultServer } from "@/utils/storage/servers";
|
||||||
import { getUser } from "@/utils/storage/user";
|
import { getUser } from "@/utils/storage/user";
|
||||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
import { useQueryErrorResetBoundary } from "@tanstack/react-query";
|
||||||
|
import { createFileRoute, redirect, useRouter } from "@tanstack/react-router";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/")({
|
export const Route = createFileRoute("/")({
|
||||||
errorComponent: (error) => {
|
|
||||||
console.error(error.error);
|
|
||||||
},
|
|
||||||
beforeLoad: async () => {
|
beforeLoad: async () => {
|
||||||
const currentServerId = await getDefaultServer();
|
const currentServerId = await getDefaultServer();
|
||||||
const userOnDisk = await getUser();
|
const userOnDisk = await getUser();
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ export const setDefaultServer = async (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Server
|
* Get a Server
|
||||||
|
* @returns {ServerInfo}
|
||||||
*/
|
*/
|
||||||
export const getServer = async (serverId: string | null) => {
|
export const getServer = async (
|
||||||
|
serverId: string | null,
|
||||||
|
): Promise<ServerInfo | undefined> => {
|
||||||
const servers = await getAllServers();
|
const servers = await getAllServers();
|
||||||
|
|
||||||
return servers.find((server) => server.id === serverId);
|
return servers.find((server) => server.id === serverId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ type ApiStore = {
|
|||||||
createApi: (serverAddress: string, accessToken?: string | undefined) => void;
|
createApi: (serverAddress: string, accessToken?: string | undefined) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export const axiosClient = axios.create({
|
export const axiosClient = axios.create({
|
||||||
// adapter: axiosTauriApiAdapter,
|
// adapter: axiosTauriApiAdapter,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -50,12 +53,7 @@ export const ApiProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
jellyfin: jellyfin,
|
jellyfin: jellyfin,
|
||||||
createApi: (serverAddress, accessToken?) =>
|
createApi: (serverAddress, accessToken?) =>
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const apiTemp = state.jellyfin.createApi(
|
const apiTemp = state.jellyfin.createApi(serverAddress, accessToken);
|
||||||
serverAddress,
|
|
||||||
accessToken,
|
|
||||||
axiosClient,
|
|
||||||
);
|
|
||||||
console.info(apiTemp);
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
api: apiTemp,
|
api: apiTemp,
|
||||||
@@ -69,7 +67,7 @@ export const ApiProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
export function useApiInContext<T>(selector?: (state: ApiStore) => T) {
|
export function useApiInContext<T>(selector?: (state: ApiStore) => T) {
|
||||||
const store = useContext(ApiContext);
|
const store = useContext(ApiContext);
|
||||||
if (!store) {
|
if (!store) {
|
||||||
throw new Error("Missing StoreProvider");
|
throw new Error("Missing ApiProvider");
|
||||||
}
|
}
|
||||||
return useStore(store, selector!);
|
return useStore(store, selector!);
|
||||||
}
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { create } from "zustand";
|
|
||||||
import { version } from "../../../package.json";
|
|
||||||
import { getAllServers, getDefaultServer, getServer } from "../storage/servers";
|
|
||||||
import { getUser } from "../storage/user";
|
|
||||||
/**
|
|
||||||
* Central Store controls the base state required by the app
|
|
||||||
*/
|
|
||||||
export const useCentralStore = create(() => ({
|
|
||||||
defaultServerOnDisk: async () => await getDefaultServer(),
|
|
||||||
defaultServerInfoOnDisk: async () => {
|
|
||||||
const a = await getDefaultServer();
|
|
||||||
return await getServer(a);
|
|
||||||
},
|
|
||||||
allServersOnDisk: async () => await getAllServers(),
|
|
||||||
userOnDisk: async () => await getUser(),
|
|
||||||
/** This is the initial route that app goes to just after app startups */
|
|
||||||
initialRoute: null,
|
|
||||||
clientVersion: version,
|
|
||||||
appReady: false,
|
|
||||||
}));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets app inital route
|
|
||||||
* @param {string} route
|
|
||||||
*/
|
|
||||||
export const setInitialRoute = (route) => {
|
|
||||||
useCentralStore.setState((state) => ({ ...state, initialRoute: route }));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setAppReady = (appReady) => {
|
|
||||||
useCentralStore.setState((state) => ({ ...state, appReady }));
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { createStore, StoreApi, useStore } from "zustand";
|
||||||
|
import { version } from "../../../package.json";
|
||||||
|
import {
|
||||||
|
getAllServers,
|
||||||
|
getDefaultServer,
|
||||||
|
getServer,
|
||||||
|
ServerInfo,
|
||||||
|
} from "../storage/servers";
|
||||||
|
import { getUser } from "../storage/user";
|
||||||
|
import { useApiInContext } from "./api";
|
||||||
|
import { Api } from "@jellyfin/sdk";
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { createContext, useContext, useState } from "react";
|
||||||
|
import { type UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { type ReactNode } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
type CentralStore = {
|
||||||
|
defaultServerOnDisk: () => Promise<string | null>;
|
||||||
|
defaultServerInfoOnDisk: () => Promise<ServerInfo | undefined>;
|
||||||
|
allServersOnDisk: () => Promise<ServerInfo[]>;
|
||||||
|
userOnDisk: () => Promise<{
|
||||||
|
Name: string;
|
||||||
|
AccessToken: string;
|
||||||
|
} | null>;
|
||||||
|
clientVersion: string;
|
||||||
|
currentUser: null | UserDto;
|
||||||
|
fetchCurrentUser: (api: Api | undefined) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets app inital route
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
export const setInitialRoute = (route) => {
|
||||||
|
// useCentralStore.setState((state) => ({ ...state, initialRoute: route }));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
export const setAppReady = (appReady) => {
|
||||||
|
// useCentralStore.setState((state) => ({ ...state, appReady }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const CentralContext = createContext<StoreApi<CentralStore>>(null!);
|
||||||
|
|
||||||
|
export const CentralProvider = ({ children }: { children: ReactNode }) => {
|
||||||
|
const [store] = useState(() =>
|
||||||
|
createStore<CentralStore>()((set) => ({
|
||||||
|
defaultServerOnDisk: async () => await getDefaultServer(),
|
||||||
|
defaultServerInfoOnDisk: async () => {
|
||||||
|
const a = await getDefaultServer();
|
||||||
|
return await getServer(a);
|
||||||
|
},
|
||||||
|
allServersOnDisk: async () => await getAllServers(),
|
||||||
|
userOnDisk: async () => await getUser(),
|
||||||
|
clientVersion: version,
|
||||||
|
currentUser: null,
|
||||||
|
fetchCurrentUser: async (api) => {
|
||||||
|
if (api) {
|
||||||
|
const user = (await getUserApi(api).getCurrentUser()).data;
|
||||||
|
set((s) => ({ ...s, currentUser: user }));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<CentralContext.Provider value={store}>{children}</CentralContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useCentralStore<T>(selector?: (state: CentralStore) => T) {
|
||||||
|
const store = useContext(CentralContext);
|
||||||
|
if (!store) {
|
||||||
|
throw new Error("Missing CentralProvider");
|
||||||
|
}
|
||||||
|
return useStore(store, selector!);
|
||||||
|
}
|
||||||
@@ -23,4 +23,12 @@ export const setTrackIndex = (index: number) => {
|
|||||||
useQueue.setState((state) => ({ ...state, currentItemIndex: index }));
|
useQueue.setState((state) => ({ ...state, currentItemIndex: index }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the Queue store
|
||||||
|
*/
|
||||||
|
export const clearQueue = () => {
|
||||||
|
useQueue.setState(useQueue.getInitialState());
|
||||||
|
};
|
||||||
|
|
||||||
export default useQueue;
|
export default useQueue;
|
||||||
Reference in new issue
Block a user