Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>

This commit is contained in:
mbrucedogs 2025-07-21 08:28:57 -05:00
parent cef20f59c5
commit 9dce7874a4

View File

@ -22,6 +22,11 @@ export const useSongOperations = () => {
try { try {
// Calculate the next order by finding the highest order value and adding 1 // Calculate the next order by finding the highest order value and adding 1
const queueItems = Object.values(currentQueue) as QueueItem[]; const queueItems = Object.values(currentQueue) as QueueItem[];
// Prevent duplicate song/singer pairs
const duplicate = queueItems.find(item => item.song.path === song.path && item.singer.name === currentSinger);
if (duplicate) {
throw new Error('This song is already in the queue for this singer.');
}
const maxOrder = queueItems.length > 0 const maxOrder = queueItems.length > 0
? Math.max(...queueItems.map(item => item.order || 0)) ? Math.max(...queueItems.map(item => item.order || 0))
: 0; : 0;