feat(web): use season backdrop in series page if available

This commit is contained in:
Prayag Prajapati committed 2024-03-12 10:51:14 +05:30
1 parent ac95c1711c
commit 68c88068f6
3 files changed
+48 -9

No files matched your search

+2 -1
View File
@@ -429,7 +429,8 @@ const SearchPage = () => {
musicAlbum.data.Items.length === 0 &&
book.data.Items.length === 0 &&
musicArtists.data.Items.length === 0 &&
person.data.Items.length === 0 && (
person.data.Items.length === 0 &&
episodes.data.SearchHints.length === 0 && (
<div
style={{
height: "calc(100vh - 12em)",
+43 -7
View File
@@ -160,6 +160,11 @@ const SeriesTitlePage = () => {
refetchOnWindowFocus: true,
});
const [backdropImage, setBackdropImage] = useState(() => {
const result = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
return result ?? "0";
});
const [currentSeason, setCurrentSeason] = useState(() => {
const result = sessionStorage.getItem(`season-${item.data?.Id}`);
return result ?? 0;
@@ -216,11 +221,15 @@ const SeriesTitlePage = () => {
useLayoutEffect(() => {
if (item.isSuccess) {
setBackdropImage(
api.getItemImageUrl(item.data?.Id, "Backdrop", {
tag: item.data?.BackdropImageTags[0],
}),
);
setAppBackdrop(
item.data.Type === BaseItemKind.MusicAlbum ||
item.data.Type === BaseItemKind.Episode
? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
: `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
api.getItemImageUrl(item.data?.Id, "Backdrop", {
tag: item.data?.BackdropImageTags[0],
}),
item.data.Id,
);
const direTp = item.data.People.filter((itm) => itm.Type === "Director");
@@ -252,6 +261,34 @@ const SeriesTitlePage = () => {
}
}, [seasons.isSuccess]);
useEffect(() => {
if (
currentSeasonItem.isSuccess &&
currentSeasonItem.data?.BackdropImageTags?.length > 0
) {
sessionStorage.setItem(
`backdrop-${item.data?.Id}`,
api.getItemImageUrl(currentSeasonItem.data.Id, "Backdrop", {
tag: currentSeasonItem.data.BackdropImageTags[0],
}),
);
setBackdropImage(
api.getItemImageUrl(currentSeasonItem.data.Id, "Backdrop", {
tag: currentSeasonItem.data.BackdropImageTags[0],
}),
currentSeasonItem.data.Id,
);
setAppBackdrop(
api.getItemImageUrl(currentSeasonItem.data.Id, "Backdrop", {
tag: currentSeasonItem.data.BackdropImageTags[0],
}),
currentSeasonItem.data.Id,
);
}
}, [currentSeasonItem.dataUpdatedAt]);
console.log(backdropImage);
const pageRef = useRef(null);
const { scrollYProgress } = useScroll({
target: pageRef,
@@ -296,10 +333,9 @@ const SeriesTitlePage = () => {
<div className="item-hero-backdrop-container">
{item.data.BackdropImageTags ? (
<motion.img
key={currentSeason}
alt={item.data.Name}
src={api.getItemImageUrl(item.data.Id, "Backdrop", {
tag: item.data.BackdropImageTags[0],
})}
src={backdropImage}
className="item-hero-backdrop"
onLoad={(e) => {
e.currentTarget.style.opacity = 1;