From 5d6dfed797e73ca91c809aff94bd1a91e3d36be3 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 31 Aug 2021 17:29:07 -0700 Subject: [PATCH] add increment on repeatOne --- src/redux/playQueueSlice.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/redux/playQueueSlice.ts b/src/redux/playQueueSlice.ts index f376831..b3ec711 100644 --- a/src/redux/playQueueSlice.ts +++ b/src/redux/playQueueSlice.ts @@ -186,6 +186,7 @@ const playQueueSlice = createSlice({ incrementCurrentIndex: (state, action: PayloadAction) => { if (state.entry.length >= 1 && state.repeat !== 'one') { if (state.currentIndex < state.entry.length - 1) { + // Check that current index isn't on the last track of the queue state.currentIndex += 1; if (action.payload === 'usingHotkey') { state.currentPlayer = 1; @@ -199,6 +200,7 @@ const playQueueSlice = createSlice({ } } } else if (state.repeat === 'all') { + // But if it is the last track, and repeat is all, then we can go back to 0 state.currentIndex = 0; if (action.payload === 'usingHotkey') { state.currentPlayer = 1; @@ -212,7 +214,17 @@ const playQueueSlice = createSlice({ } } } - + state.currentSongId = state.entry[state.currentIndex].id; + } else if (state.entry.length >= 1 && state.repeat === 'one') { + // If repeating one, then we can just increment to the next track + state.currentIndex += 1; + if (action.payload === 'usingHotkey') { + state.currentPlayer = 1; + state.isFading = false; + state.player1.volume = state.volume; + state.player1.index = state.currentIndex; + state.player2.index = state.currentIndex; + } state.currentSongId = state.entry[state.currentIndex].id; } },