Skip to content

Commit

Permalink
chore: general improvements
Browse files Browse the repository at this point in the history
Signed-off-by: mateonunez <mateonunez95@gmail.com>
  • Loading branch information
mateonunez committed Nov 25, 2024
1 parent bf5abda commit 7f9cfc8
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 80 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ yarn-error.log*
# Synk
.dccache
.yarn
.pnp.cjs
.pnp.loader.mjs
1 change: 1 addition & 0 deletions app/api/spotify/currently-listening/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export async function GET() {
const response = await getCurrentlyListening();

if (!response) {
console.log(response);
return NextResponse.json({ error: 'Spotify not available' }, { status: 503 });
}

Expand Down
15 changes: 11 additions & 4 deletions components/spotify/player/player.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const Player = () => {

const url = listening?.isPlaying ? listening.url : `${config.baseUrl}/spotify`;

const progress = useMemo(() => listening && (listening.progress / listening.duration) * 100, [listening]);
const progress = useMemo(() => {
if (listening?.isPlaying) {
const duration = listening.duration;
const progress = listening.progress;
return (progress / duration) * 100;
}
return 0;
}, [listening]);

return (
<>
Expand All @@ -36,12 +43,12 @@ const Player = () => {
href={url}
>
{listening?.isPlaying ? (
<div className="h-auto w-auto">
<div className="w-auto h-auto">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img width="40" height="40" src={listening?.thumbnail} alt={listening?.album} />
</div>
) : (
<Spotify className="h-10 w-10" color={'#1ED760'} />
<Spotify className="w-10 h-10" color={'#1ED760'} />
)}
</Link>

Expand All @@ -60,7 +67,7 @@ const Player = () => {
rel="noopener noreferer noreferrer"
title="Mateo Nunez on Spotify"
>
<ChevronUp className="h-4 w-4 rotate-90" />
<ChevronUp className="w-4 h-4 rotate-90" />
</Link>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions lib/spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const getAccessToken = async () => {
export const getCurrentlyListening = async () => {
const { access_token: accessToken } = await getAccessToken();
if (!accessToken) {
console.log('accessToken', accessToken);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "biome format ./ --write"
},
"dependencies": {
"next": "^14.2.3",
"next": "^15.0.3",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand All @@ -18,7 +18,7 @@
"@elgorditosalsero/react-gtm-hook": "^2.7.2",
"@mdx-js/loader": "^3.0.1",
"@octokit/graphql": "^8.1.1",
"@tailwindcss/typography": "^0.5.13",
"@tailwindcss/typography": "^0.5.15",
"@vercel/analytics": "^1.2.2",
"autoprefixer": "^10.4.19",
"classnames": "^2.5.1",
Expand Down
Binary file modified public/images/profile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7f9cfc8

Please sign in to comment.