Skip to content

Commit

Permalink
Feat(NavbarProfilePicture): Use useSession Hook
Browse files Browse the repository at this point in the history
  • Loading branch information
WillKirkmanM committed Oct 7, 2024
1 parent d5e21ee commit 6ca2efe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/web/components/User/NavbarProfilePicture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Inter as FontSans } from "next/font/google"
import { useRouter } from "next/navigation"
import { useEffect, useState } from "react"
import { cn } from "@music/ui/lib/utils"
import { useSession } from "../Providers/AuthProvider"

const fontSans = FontSans({
subsets: ["latin"],
Expand All @@ -42,10 +43,10 @@ const fontSans = FontSans({
export default function NavbarProfilePicture() {
const [username, setUsername] = useState("")
const [profilePicture, setProfilePicture] = useState<string | null>(null)
const { session } = useSession()

useEffect(() => {
const fetchSessionAndProfilePicture = async () => {
const session = getSession()
if (session) {
setUsername(session.username)
const profilePic = await getProfilePicture(Number(session.sub))
Expand All @@ -57,7 +58,7 @@ export default function NavbarProfilePicture() {
}
}
fetchSessionAndProfilePicture()
}, [])
}, [session])

const { push } = useRouter()
function signOut() {
Expand Down

0 comments on commit 6ca2efe

Please sign in to comment.