Fix #1092: Ensure player doesn't disappear when last queue track is removed manually

merge-requests/1094/merge
Agate 2020-05-07 17:50:20 +02:00
rodzic 1638a319cb
commit b6a183f600
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6B501DFD73514E14
3 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -0,0 +1 @@
Ensure player doesn't disappear when last queue track is removed manually (#1092)

Wyświetl plik

@ -104,8 +104,13 @@ export default {
commit('splice', {start: index, size: 1})
if (index < state.currentIndex) {
commit('currentIndex', state.currentIndex - 1)
}
if (current) {
} else if (index > 0 && index === state.tracks.length) {
// kind of a edge case: if you delete the last track of the queue
// we set current index to the previous one to avoid the queue tab from
// being stuck because the player disappeared
// cf #1092
commit('currentIndex', state.tracks.length - 1)
} else if (current) {
// we play next track, which now have the same index
commit('currentIndex', index)
}

Wyświetl plik

@ -133,7 +133,7 @@ describe('store/queue', () => {
testAction({
action: store.actions.cleanTrack,
payload: 3,
params: {state: {currentIndex: 2, tracks: []}},
params: {state: {currentIndex: 2, tracks: [1, 2, 3, 4, 5]}},
expectedMutations: [
{ type: 'splice', payload: {start: 3, size: 1} }
]