mirror of
https://github.com/jeffvli/sonixd.git
synced 2026-04-30 11:12:36 -04:00
Add redux logic to append tracks next
This commit is contained in:
@@ -16,7 +16,8 @@ export interface Modal {
|
||||
|
||||
type ContextMenuOptions =
|
||||
| 'play'
|
||||
| 'addToQueue'
|
||||
| 'addToQueueNext'
|
||||
| 'addToQueueLast'
|
||||
| 'removeFromCurrent'
|
||||
| 'addToPlaylist'
|
||||
| 'deletePlaylist'
|
||||
|
||||
@@ -783,7 +783,10 @@ const playQueueSlice = createSlice({
|
||||
}
|
||||
},
|
||||
|
||||
appendPlayQueue: (state, action: PayloadAction<{ entries: Entry[] }>) => {
|
||||
appendPlayQueue: (
|
||||
state,
|
||||
action: PayloadAction<{ entries: Entry[]; type: 'next' | 'later' }>
|
||||
) => {
|
||||
const wasPlaying = state.entry.length > 0;
|
||||
// We'll need to update the uniqueId otherwise selecting a song with duplicates
|
||||
// will select them all at once
|
||||
@@ -794,12 +797,28 @@ const playQueueSlice = createSlice({
|
||||
};
|
||||
});
|
||||
|
||||
refreshedEntries.map((entry: any) => state.entry.push(entry));
|
||||
if (action.payload.type === 'later') {
|
||||
refreshedEntries.map((entry: any) => state.entry.push(entry));
|
||||
} else {
|
||||
state.entry = [
|
||||
...state.entry.slice(0, state.currentIndex + 1),
|
||||
...refreshedEntries,
|
||||
...state.entry.slice(state.currentIndex + 1),
|
||||
];
|
||||
}
|
||||
|
||||
if (state.shuffle) {
|
||||
// If shuffle is enabled, add all entries randomly
|
||||
const shuffledEntries = _.shuffle(action.payload.entries);
|
||||
shuffledEntries.map((entry: any) => state.shuffledEntry.push(entry));
|
||||
const shuffledEntries = _.shuffle(refreshedEntries);
|
||||
if (action.payload.type === 'later') {
|
||||
shuffledEntries.map((entry: any) => state.shuffledEntry.push(entry));
|
||||
} else {
|
||||
state.shuffledEntry = [
|
||||
...state.shuffledEntry.slice(0, state.currentIndex + 1),
|
||||
...shuffledEntries,
|
||||
...state.shuffledEntry.slice(state.currentIndex + 1),
|
||||
];
|
||||
}
|
||||
if (!wasPlaying) {
|
||||
state.current = { ...shuffledEntries[0] };
|
||||
state.currentSongId = shuffledEntries[0].id;
|
||||
|
||||
Reference in New Issue
Block a user