Updated Queue and Main View song keys to include random numbers to prevent duplicates

This commit is contained in:
MrDulfin 2025-03-24 19:18:38 -04:00
parent 8f30c38c4c
commit fce2927986

View file

@ -48,14 +48,14 @@ function App() {
const unlisten = appWindow.listen<any>("queue_updated", (_) => { const unlisten = appWindow.listen<any>("queue_updated", (_) => {
// console.log(event); // console.log(event);
invoke('get_queue').then((_songs) => { invoke('get_queue').then((_songs) => {
let songs = _songs as any[] let songs = _songs as any[];
setQueue( setQueue(
songs.filter((_, i) => i != 0).map((song, i) => songs.filter((_, i) => i != 0).map((song, i) =>
<QueueSong <QueueSong
song={ song[0] } song={ song[0] }
location={ song[1] as "Library" | {"Playlist" : string}} location={ song[1] as "Library" | {"Playlist" : string}}
index={i+1} index={i+1}
key={ song.uuid + '_' + Math.floor((Math.random() * 100_000) + 1) + '_' + Date.now() } key={ Math.floor((Math.random() * 100_000_000_000) + 1) + '_' + Date.now() }
/> />
) )
) )
@ -126,7 +126,7 @@ function PlaylistHead({ playlists, setPlaylists, setViewName, setLibrary }: Play
// console.log(song); // console.log(song);
return ( return (
<Song <Song
key={ song.uuid } key={ song.uuid + Math.floor(Math.random() * 100_000_000_000) }
location={ song.location } location={ song.location }
playerLocation={ {"Playlist" : item.uuid } } playerLocation={ {"Playlist" : item.uuid } }
uuid={ song.uuid } uuid={ song.uuid }
@ -221,7 +221,7 @@ function MainView({ lib_ref, viewName }: MainViewProps) {
return ( return (
<Song <Song
key={ song.uuid } key={ song.uuid + Math.floor(Math.random() * 100_000_000_000) }
location={ song.location } location={ song.location }
playerLocation="Library" playerLocation="Library"
uuid={ song.uuid } uuid={ song.uuid }