Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Von
funkwhale
Commits
456661a3
Verified
Commit
456661a3
authored
Nov 25, 2018
by
Eliot Berriot
Browse files
Fix #209: skipped track when appending multiple tracks to the queue under certain conditions (#209)
parent
422eb92f
Changes
3
Hide whitespace changes
Inline
Side-by-side
changes/changelog.d/209.bugfix
0 → 100644
View file @
456661a3
Fixed skipped track when appending multiple tracks to the queue under certain conditions (#209)
front/src/store/queue.js
View file @
456661a3
...
...
@@ -59,7 +59,7 @@ export default {
isEmpty
:
state
=>
state
.
tracks
.
length
===
0
},
actions
:
{
append
({
commit
,
state
,
dispatch
},
{
track
,
index
,
skipPlay
})
{
append
({
commit
,
state
,
dispatch
},
{
track
,
index
})
{
index
=
index
||
state
.
tracks
.
length
if
(
index
>
state
.
tracks
.
length
-
1
)
{
// we simply push to the end
...
...
@@ -68,9 +68,6 @@ export default {
// we insert the track at given position
commit
(
'
insert
'
,
{
track
,
index
})
}
if
(
!
skipPlay
)
{
dispatch
(
'
resume
'
)
}
},
appendMany
({
state
,
dispatch
},
{
tracks
,
index
,
callback
})
{
...
...
@@ -82,13 +79,12 @@ export default {
}
let
total
=
tracks
.
length
tracks
.
forEach
((
t
,
i
)
=>
{
let
p
=
dispatch
(
'
append
'
,
{
track
:
t
,
index
:
index
,
skipPlay
:
true
})
let
p
=
dispatch
(
'
append
'
,
{
track
:
t
,
index
:
index
})
index
+=
1
if
(
callback
&&
i
+
1
===
total
)
{
p
.
then
(
callback
)
}
})
dispatch
(
'
resume
'
)
},
cleanTrack
({
state
,
dispatch
,
commit
},
index
)
{
...
...
@@ -110,11 +106,6 @@ export default {
}
},
resume
({
state
,
dispatch
,
rootState
})
{
if
(
state
.
ended
|
rootState
.
player
.
errored
)
{
dispatch
(
'
next
'
)
}
},
previous
({
state
,
dispatch
,
rootState
})
{
if
(
state
.
currentIndex
>
0
&&
rootState
.
player
.
currentTime
<
3
)
{
dispatch
(
'
currentIndex
'
,
state
.
currentIndex
-
1
)
...
...
front/tests/unit/specs/store/queue.spec.js
View file @
456661a3
...
...
@@ -88,7 +88,7 @@ describe('store/queue', () => {
it
(
'
append at end
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
append
,
payload
:
{
track
:
4
,
skipPlay
:
true
},
payload
:
{
track
:
4
},
params
:
{
state
:
{
tracks
:
[
1
,
2
,
3
]}},
expectedMutations
:
[
{
type
:
'
insert
'
,
payload
:
{
track
:
4
,
index
:
3
}
}
...
...
@@ -98,26 +98,13 @@ describe('store/queue', () => {
it
(
'
append at index
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
append
,
payload
:
{
track
:
2
,
index
:
1
,
skipPlay
:
true
},
payload
:
{
track
:
2
,
index
:
1
},
params
:
{
state
:
{
tracks
:
[
1
,
3
]}},
expectedMutations
:
[
{
type
:
'
insert
'
,
payload
:
{
track
:
2
,
index
:
1
}
}
]
})
})
it
(
'
append and play
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
append
,
payload
:
{
track
:
3
},
params
:
{
state
:
{
tracks
:
[
1
,
2
]}},
expectedMutations
:
[
{
type
:
'
insert
'
,
payload
:
{
track
:
3
,
index
:
2
}
}
],
expectedActions
:
[
{
type
:
'
resume
'
}
]
})
})
it
(
'
appendMany
'
,
()
=>
{
const
tracks
=
[{
title
:
1
},
{
title
:
2
}]
testAction
({
...
...
@@ -125,9 +112,8 @@ describe('store/queue', () => {
payload
:
{
tracks
:
tracks
},
params
:
{
state
:
{
tracks
:
[]}},
expectedActions
:
[
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
0
],
index
:
0
,
skipPlay
:
true
}
},
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
1
],
index
:
1
,
skipPlay
:
true
}
},
{
type
:
'
resume
'
}
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
0
],
index
:
0
}
},
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
1
],
index
:
1
}
},
]
})
})
...
...
@@ -138,9 +124,8 @@ describe('store/queue', () => {
payload
:
{
tracks
:
tracks
,
index
:
1
},
params
:
{
state
:
{
tracks
:
[
1
,
2
]}},
expectedActions
:
[
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
0
],
index
:
1
,
skipPlay
:
true
}
},
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
1
],
index
:
2
,
skipPlay
:
true
}
},
{
type
:
'
resume
'
}
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
0
],
index
:
1
}
},
{
type
:
'
append
'
,
payload
:
{
track
:
tracks
[
1
],
index
:
2
}
},
]
})
})
...
...
@@ -179,31 +164,6 @@ describe('store/queue', () => {
]
})
})
it
(
'
resume when ended
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
resume
,
params
:
{
state
:
{
ended
:
true
},
rootState
:
{
player
:
{
errored
:
false
}}},
expectedActions
:
[
{
type
:
'
next
'
}
]
})
})
it
(
'
resume when errored
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
resume
,
params
:
{
state
:
{
ended
:
false
},
rootState
:
{
player
:
{
errored
:
true
}}},
expectedActions
:
[
{
type
:
'
next
'
}
]
})
})
it
(
'
skip resume when not ended or not error
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
resume
,
params
:
{
state
:
{
ended
:
false
},
rootState
:
{
player
:
{
errored
:
false
}}},
expectedActions
:
[]
})
})
it
(
'
previous when at beginning
'
,
()
=>
{
testAction
({
action
:
store
.
actions
.
previous
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment