From 59e8ceb99c41defcc2b1c22342ca1584c48cf0bc Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 19 Sep 2023 18:44:45 +0530 Subject: [PATCH] Fix few things --- src/App.jsx | 6 +- src/components/buttons/playButton.jsx | 1 - src/components/layouts/artist/artistAlbum.jsx | 3 - src/components/layouts/item/hero.jsx | 8 ++- src/components/musicTrack/index.jsx | 6 +- src/components/playback/audioPlayer/index.jsx | 7 +- src/main.jsx | 2 +- src/routes/album/index.jsx | 4 +- src/routes/artist/index.jsx | 43 +------------ src/routes/boxset/index.jsx | 64 +++---------------- src/routes/item/index.jsx | 7 +- 11 files changed, 38 insertions(+), 113 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 155ebe9..f9efb4e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -266,7 +266,11 @@ function App() { await delUser(); await relaunch(); }; + const location = useLocation(); + useEffect(() => { + window.scrollTo(0, 0); + }, [location.pathname]); if (!window.api) { serverAvailable().then((available) => { @@ -515,7 +519,7 @@ function App() { - + {/* */} ); diff --git a/src/components/buttons/playButton.jsx b/src/components/buttons/playButton.jsx index ef3f6c1..762622b 100644 --- a/src/components/buttons/playButton.jsx +++ b/src/components/buttons/playButton.jsx @@ -123,7 +123,6 @@ const PlayButton = ({ return result.data; }, onSuccess: (item) => { - console.log(item); if (audio) { setAudioTracks(item.Items); setAudioUrl( diff --git a/src/components/layouts/artist/artistAlbum.jsx b/src/components/layouts/artist/artistAlbum.jsx index 01f647f..7605443 100644 --- a/src/components/layouts/artist/artistAlbum.jsx +++ b/src/components/layouts/artist/artistAlbum.jsx @@ -176,9 +176,6 @@ export const ArtistAlbum = ({ user, album, boxProps }) => { justifySelf: "start", }} fontWeight={400} - onClick={() => { - console.log("Hvnrjn"); - }} > Name diff --git a/src/components/layouts/item/hero.jsx b/src/components/layouts/item/hero.jsx index 97254a7..3d26ec9 100644 --- a/src/components/layouts/item/hero.jsx +++ b/src/components/layouts/item/hero.jsx @@ -1,7 +1,7 @@ /** @format */ import PropTypes from "prop-types"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useRef } from "react"; import TextField from "@mui/material/TextField"; import MenuItem from "@mui/material/MenuItem"; import Chip from "@mui/material/Chip"; @@ -64,6 +64,8 @@ const Hero = ({ albumBy, audioPlayButton = false, }) => { + const backgroundRef = useRef(null); + const filterMediaStreamVideo = (source) => { if (source.Type == MediaStreamType.Video) { return true; @@ -108,7 +110,7 @@ const Hero = ({ marginBottom: "2em", }} > -
+
{!!item.ImageBlurHashes.Backdrop && ( <> {Object.keys(item.ImageBlurHashes.Backdrop) @@ -591,7 +593,7 @@ const Hero = ({ Directed by
- {directors.map((director) => ( + {directors.map((director, index) => ( <> { : item.Id, "Primary", { - quality: 85, - fillHeight: 462, - fillWidth: 462, + quality: 70, + fillHeight: 128, + fillWidth: 128, }, )} style={{ diff --git a/src/components/playback/audioPlayer/index.jsx b/src/components/playback/audioPlayer/index.jsx index 949c1be..5beecea 100644 --- a/src/components/playback/audioPlayer/index.jsx +++ b/src/components/playback/audioPlayer/index.jsx @@ -172,9 +172,10 @@ const AudioPlayer = () => { }; return ( - + {display && ( { 13, )} - 10px)`, }} + transition={{ + duration: 0.1, + ease: "easeInOut", + }} className="audio-player" > { let result = await getLibraryApi(window.api).getSimilarAlbums({ userId: user.data.Id, itemId: item.data.Id, + limit: 16, }); return result.data; }, @@ -232,9 +233,6 @@ const MusicAlbumTitlePage = () => { justifySelf: "start", }} fontWeight={400} - onClick={() => { - console.log("Hvnrjn"); - }} > Name diff --git a/src/routes/artist/index.jsx b/src/routes/artist/index.jsx index c3d799c..199a012 100644 --- a/src/routes/artist/index.jsx +++ b/src/routes/artist/index.jsx @@ -132,43 +132,6 @@ const ArtistTitlePage = () => { refetchOnWindowFocus: true, }); - const similarItems = useQuery({ - queryKey: ["item", id, "similarItem"], - queryFn: async () => { - let result; - if (item.data.Type == "Movie") { - result = await getLibraryApi(window.api).getSimilarMovies({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "Series") { - result = await getLibraryApi(window.api).getSimilarShows({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "MusicAlbum") { - result = await getLibraryApi(window.api).getSimilarAlbums({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "MusicArtist") { - result = await getLibraryApi(window.api).getSimilarArtists({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else { - result = await getLibraryApi(window.api).getSimilarItems({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } - return result.data; - }, - enabled: item.isSuccess, - networkMode: "always", - refetchOnWindowFocus: true, - }); - const artistDiscography = useQuery({ queryKey: ["item", id, "artist", "discography"], queryFn: async () => { @@ -266,7 +229,7 @@ const ArtistTitlePage = () => { } }, [item.isSuccess]); - if (item.isLoading || similarItems.isLoading) { + if (item.isLoading) { return ( { ); } - if (item.isSuccess && similarItems.isSuccess) { + if (item.isSuccess) { return (
{
); } - if (item.isError || similarItems.isError) { + if (item.isError) { return ; } }; diff --git a/src/routes/boxset/index.jsx b/src/routes/boxset/index.jsx index ce2911a..e46b713 100644 --- a/src/routes/boxset/index.jsx +++ b/src/routes/boxset/index.jsx @@ -101,33 +101,11 @@ const BoxSetTitlePage = () => { const similarItems = useQuery({ queryKey: ["item", id, "similarItem"], queryFn: async () => { - let result; - if (item.data.Type == "Movie") { - result = await getLibraryApi(window.api).getSimilarMovies({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "Series") { - result = await getLibraryApi(window.api).getSimilarShows({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "MusicAlbum") { - result = await getLibraryApi(window.api).getSimilarAlbums({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else if (item.data.Type == "MusicArtist") { - result = await getLibraryApi(window.api).getSimilarArtists({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } else { - result = await getLibraryApi(window.api).getSimilarItems({ - userId: user.data.Id, - itemId: item.data.Id, - }); - } + const result = await getLibraryApi(window.api).getSimilarItems({ + userId: user.data.Id, + itemId: item.data.Id, + limit: 16, + }); return result.data; }, enabled: item.isSuccess, @@ -240,39 +218,13 @@ const BoxSetTitlePage = () => { } imageType={"Primary"} cardCaption={ - similar.Type == - BaseItemKind.Episode - ? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}` - : similar.Type == - BaseItemKind.Series - ? `${ - similar.ProductionYear - } - ${ - !!similar.EndDate - ? new Date( - similar.EndDate, - ).toLocaleString( - [], - { - year: "numeric", - }, - ) - : "Present" - }` - : similar.ProductionYear - } - cardType={ - similar.Type == - BaseItemKind.MusicAlbum || - similar.Type == - BaseItemKind.Audio - ? "square" - : "portrait" + similar.ProductionYear } + cardType={"portrait"} queryKey={[ "item", id, - "similarItem", + `collection`, ]} userId={user.data.Id} imageBlurhash={ diff --git a/src/routes/item/index.jsx b/src/routes/item/index.jsx index b7cd5c9..a2a4f3e 100644 --- a/src/routes/item/index.jsx +++ b/src/routes/item/index.jsx @@ -1,5 +1,5 @@ /** @format */ -import { useState, useEffect } from "react"; +import { useState, useEffect, useRef } from "react"; import PropTypes from "prop-types"; import Box from "@mui/material/Box"; @@ -139,6 +139,7 @@ const ItemDetail = () => { result = await getLibraryApi(window.api).getSimilarMovies({ userId: user.data.Id, itemId: item.data.Id, + limit: 16, }); } else if (item.data.Type == "Series") { result = await getLibraryApi(window.api).getSimilarShows({ @@ -566,6 +567,8 @@ const ItemDetail = () => { } }, [item.isSuccess]); + const backdropRef = useRef(null); + if (item.isLoading || similarItems.isLoading) { return ( { flexDirection: "column", gap: "0.5em", }} + ref={backdropRef} > { videoTracks={videoTracks} audioTracks={audioTracks} subtitleTracks={subtitleTracks} + backdropRef={backdropRef} /> {item.data.People.length > 0 && (