Skip to content

Commit 5a98d62

Browse files
committed
bugfixes
1 parent 37b3a07 commit 5a98d62

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/app/session/[id]/client.tsx

+12-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from "uuid";
77
import { ProgressBar, millisecondsToString } from './progressbar';
88
import { getValue } from '@/src/utils';
99
import { EndSessionOverlay } from "@/src/app/session/[id]/EndSessionOverlay"
10+
import { Socket } from 'socket.io-client'
1011

1112

1213
const Toast: React.FC<{ message: string; onClose: () => void; }> = ({ message, onClose }) => {
@@ -53,11 +54,10 @@ export function Session ({
5354
}
5455

5556
// A new component for the "now playing" layout
56-
function NowPlayingCard({albumCover, trackTitle, artistName, progress, songlength, isPlaying, isHost, onPlayPause, onSkip}: {
57-
albumCover?: string; trackTitle?: string, artistName?: string, progress: number, songlength: number, isPlaying: boolean, isHost : boolean, onPlayPause: () => void, onSkip: () => void
57+
function NowPlayingCard({albumCover, trackTitle, artistName, progress, songlength, isPlaying, isHost, socket, onPlayPause, onSkip}: {
58+
albumCover?: string; trackTitle?: string, artistName?: string, progress: number, songlength: number, isPlaying: boolean, isHost : boolean, socket : any, onPlayPause: () => void, onSkip: () => void
5859
}) {
5960

60-
6161
return (
6262
<div
6363
className="now-playing-card"
@@ -301,10 +301,6 @@ function Queue({isHost, initQueue, socket, username, sid
301301
headers: { 'Content-Type': 'application/json' },
302302
body: JSON.stringify({ songName: input, sid: sid })
303303
})
304-
.then((response) => {
305-
if (!response.ok) throw Error(response.statusText);
306-
return response.json();
307-
})
308304
.then((response) => {
309305
if (!response.ok) throw Error(response.statusText);
310306
return response.json();
@@ -323,6 +319,7 @@ function Queue({isHost, initQueue, socket, username, sid
323319
tmp[i] = songProps;
324320
}
325321
// Update UI component with new search data
322+
console.log(tmp)
326323
setSongQuery(tmp);
327324
}).catch((error) => console.log(error));
328325
};
@@ -360,13 +357,13 @@ function Queue({isHost, initQueue, socket, username, sid
360357

361358
const handleSkip = () => {
362359
fetch(`${process.env.NEXT_PUBLIC_APP_SERVER}/api/spotify/skip`, {
363-
method: 'POST',
364-
headers: { 'Content-Type': 'application/json' },
365-
body: JSON.stringify({ sid: sid })
360+
method: 'POST',
361+
headers: { 'Content-Type': 'application/json' },
362+
body: JSON.stringify({ sid: sid })
366363
})
367364
.then(response => {
368-
if (!response.ok) throw new Error('Skip failed');
369-
socket.emit('AddedSong'); // Refresh queue
365+
if (!response.ok) throw new Error('Skip failed');
366+
socket.emit('AddedSong'); // Refresh queue
370367
})
371368
.catch(error => console.error('Skip error:', error));
372369
};
@@ -412,6 +409,7 @@ function Queue({isHost, initQueue, socket, username, sid
412409
songlength={songlength}
413410
isPlaying={isPlaying}
414411
isHost={isHost}
412+
socket={socket}
415413
onPlayPause={handlePlayPause}
416414
onSkip={handleSkip}
417415
/>
@@ -430,7 +428,7 @@ function Queue({isHost, initQueue, socket, username, sid
430428
<h1 className="queue-header">Queue</h1>
431429
<div id="SongList">
432430
{upcomingQueue.map((song, index) => (
433-
<div key={index}>
431+
<div key={`${song.songId}${song.placement}`}>
434432
<Song
435433
id={song.songId}
436434
name={song.songName}
@@ -473,7 +471,7 @@ function Queue({isHost, initQueue, socket, username, sid
473471
scrollbarWidth: 'none',
474472
}}>
475473
{songQuery.map((song, index) => (
476-
<button onClick={() => {handleAddSong(song.songId)}} key={index} className="lookup-song-button">
474+
<button onClick={() => {handleAddSong(song.songId)}} key={`${song.songId}${song.placement}`} className="lookup-song-button">
477475
<Song
478476
id={song.songId}
479477
name={song.songName}

0 commit comments

Comments
 (0)