diff --git a/src/components/buttons/likeButton.tsx b/src/components/buttons/likeButton.tsx
index 4a2e532..593dde7 100644
--- a/src/components/buttons/likeButton.tsx
+++ b/src/components/buttons/likeButton.tsx
@@ -20,7 +20,7 @@ export default function LikeButton({
isFavorite: boolean | undefined;
queryKey: string[] | undefined;
userId: string | undefined;
- itemName: string | undefined;
+ itemName?: string | null;
}) {
const api = useApiInContext((s) => s.api);
const queryClient = useQueryClient();
diff --git a/src/components/buttons/markPlayedButton.tsx b/src/components/buttons/markPlayedButton.tsx
index 908808b..8fed2da 100644
--- a/src/components/buttons/markPlayedButton.tsx
+++ b/src/components/buttons/markPlayedButton.tsx
@@ -20,7 +20,7 @@ export default function MarkPlayedButton({
isPlayed?: boolean;
queryKey?: string[];
userId?: string;
- itemName?: string;
+ itemName?: string | null;
}) {
const api = useApiInContext((s) => s.api);
diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx
index 67250e7..727cfa6 100644
--- a/src/components/buttons/playButton.tsx
+++ b/src/components/buttons/playButton.tsx
@@ -145,7 +145,15 @@ const PlayButton = ({
seasonId: item.SeasonId,
// startItemId: item.Id,
});
- index = result.data.Items?.map((i) => i.Id).indexOf(item.Id) ?? 0;
+ if (
+ result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) &&
+ result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) >
+ -1
+ ) {
+ index = result.data.Items?.map((i) => i.Id).indexOf(
+ currentEpisodeId,
+ );
+ }
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
audioStreamIndex: currentAudioTrack,
subtitleStreamIndex:
@@ -180,11 +188,14 @@ const PlayButton = ({
enableUserData: true,
userId: userId,
});
- index =
- result.data.Items?.map((i) => i.Id).indexOf(
- currentEpisodeId ?? "",
- ) ?? 0;
-
+ if (
+ result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) &&
+ result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) > -1
+ ) {
+ index = result.data.Items?.map((i) => i.Id).indexOf(
+ currentEpisodeId,
+ );
+ }
if (
result.data.Items?.[index]?.Id &&
result.data.Items?.[index].MediaSources?.[0]?.Id
@@ -475,7 +486,7 @@ const PlayButton = ({
if (!item.Id) {
throw new Error("Item ID is not available");
}
- let data: BaseItemDtoQueryResult | undefined;
+ let data: BaseItemDtoQueryResult | null = null;
const continueWatching = await getItemsApi(api).getResumeItems({
userId: userId,
limit: 1,
@@ -493,10 +504,12 @@ const PlayButton = ({
data = continueWatching.data;
} else if ((nextUp.data.Items?.length ?? 0) > 0) {
data = nextUp.data;
+ } else {
+ return null;
}
return data;
},
- enabled: itemType === BaseItemKind.Series,
+ // enabled: itemType === BaseItemKind.Series,
});
return (
- Watch S{currentEpisode.data?.Items?.[0].ParentIndexNumber}E
+ Watch S{currentEpisode.data?.Items?.[0].ParentIndexNumber ?? 1}E
{currentEpisode.data?.Items?.[0]?.IndexNumber ?? 1}
{
const api = useApiInContext((s) => s.api);
@@ -74,20 +73,20 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
className="hero-carousel-background-image"
src={
item.ParentBackdropItemId
- ? `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
- : `${api.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
+ ? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
+ : `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
}
style={{
opacity: 0,
}}
onLoad={(e) => {
- e.target.style.opacity = 1;
+ e.currentTarget.style.opacity = "1";
}}
loading="eager"
/>
) : (
- {getTypeIcon(item.Type)}
+ {getTypeIcon(item.Type ?? "Movie")}
)}
@@ -129,16 +128,16 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
item.Name
) : (
{
- e.target.style.opacity = 1;
+ e.currentTarget.style.opacity = "1";
}}
/>
)}
@@ -240,15 +239,21 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
)}
- {item.RunTimeTicks && (
+ {item.RunTimeTicks ? (
{getRuntime(item.RunTimeTicks)}
+ ) : (
+ <>>
)}
- {item.RunTimeTicks && (
+ {item.RunTimeTicks ? (
- {endsAt(item.RunTimeTicks - item.UserData.PlaybackPositionTicks)}
+ {endsAt(
+ item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
+ )}
+ ) : (
+ <>>
)}
{item.Genres?.slice(0, 4).join(" / ")}
@@ -305,16 +310,14 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
>
{