mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
fix shuffle order in usePlayerData
This commit is contained in:
@@ -2234,9 +2234,26 @@ export const usePlayerData = (): PlayerData => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const currentSong = queue.items[queueIndex];
|
const currentSong = queue.items[queueIndex];
|
||||||
const previousSong = queueIndex > 0 ? queue.items[queueIndex - 1] : undefined;
|
|
||||||
const repeat = state.player.repeat;
|
const repeat = state.player.repeat;
|
||||||
|
|
||||||
|
// For previousSong calculation, we need to consider the shuffled order (only if not in priority mode)
|
||||||
|
let previousSong: QueueSong | undefined;
|
||||||
|
if (isShuffleEnabled(state)) {
|
||||||
|
// Calculate previous in shuffled order
|
||||||
|
const previousShuffledIndex = index - 1;
|
||||||
|
if (previousShuffledIndex >= 0) {
|
||||||
|
const previousQueueIndex = state.queue.shuffled[previousShuffledIndex];
|
||||||
|
previousSong = queue.items[previousQueueIndex];
|
||||||
|
} else if (repeat === PlayerRepeat.ALL) {
|
||||||
|
// Wrap to last in shuffled order
|
||||||
|
const lastShuffledIndex = state.queue.shuffled.length - 1;
|
||||||
|
const lastQueueIndex = state.queue.shuffled[lastShuffledIndex];
|
||||||
|
previousSong = queue.items[lastQueueIndex];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
previousSong = queueIndex > 0 ? queue.items[queueIndex - 1] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
// For nextSong calculation, we need to consider the shuffled order (only if not in priority mode)
|
// For nextSong calculation, we need to consider the shuffled order (only if not in priority mode)
|
||||||
let nextSong: QueueSong | undefined;
|
let nextSong: QueueSong | undefined;
|
||||||
if (isShuffleEnabled(state)) {
|
if (isShuffleEnabled(state)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user