diff --git a/frontend/src/components/Home/Home.jsx b/frontend/src/components/Home/Home.jsx index 651c96e..25b2a39 100644 --- a/frontend/src/components/Home/Home.jsx +++ b/frontend/src/components/Home/Home.jsx @@ -9,11 +9,15 @@ import { fetchTopSongs, fetchSonsgByName, secIntoMinSec } from "../../Utils"; import { db } from "../Auth/firebase"; import { doc, getDoc } from "firebase/firestore"; -function Main() { +function Main({ topSongs }) { const [currentArtist, setCurrentArtist] = useState(null); const [currentSong, setCurrentSong] = useState([]); const [recentlyPlayedSongs, setRecentlyPlayedSongs] = useState([]); + useEffect(() => { + setCurrentSong(topSongs.length > 0 ? topSongs[0] : topSongs) + }, [topSongs]) + useEffect(() => { const fetchRecentlyPlayedSongs = async () => { try { @@ -46,9 +50,8 @@ function Main() { } else { console.log("User document does not exist"); } - } else { - console.log("User details not available"); } + console.log("User details not available"); } catch (error) { console.error("Error fetching recently played songs:", error); } @@ -80,6 +83,7 @@ function Main() {