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
Philipp Wolfer
funkwhale
Commits
5a74d1d3
Commit
5a74d1d3
authored
Sep 25, 2021
by
Georg Krause
Browse files
Fix linting errors in touched files
parent
9bef2304
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
front/src/components/Queue.vue
View file @
5a74d1d3
...
...
@@ -207,20 +207,18 @@
</section>
</template>
<
script
>
import
{
mapState
,
mapGetters
,
mapActions
}
from
"
vuex
"
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
import
$
from
'
jquery
'
import
moment
from
"
moment
"
import
moment
from
'
moment
'
import
lodash
from
'
@/lodash
'
import
time
from
"
@/utils/time
"
import
time
from
'
@/utils/time
'
import
createFocusTrap
from
'
focus-trap
'
import
store
from
"
@/store
"
export
default
{
components
:
{
TrackFavoriteIcon
:
()
=>
import
(
/* webpackChunkName: "auth-audio" */
"
@/components/favorites/TrackFavoriteIcon
"
),
TrackPlaylistIcon
:
()
=>
import
(
/* webpackChunkName: "auth-audio" */
"
@/components/playlists/TrackPlaylistIcon
"
),
VolumeControl
:
()
=>
import
(
/* webpackChunkName: "audio" */
"
@/components/audio/VolumeControl
"
),
draggable
:
()
=>
import
(
/* webpackChunkName: "draggable" */
"
vuedraggable
"
),
TrackFavoriteIcon
:
()
=>
import
(
/* webpackChunkName: "auth-audio" */
'
@/components/favorites/TrackFavoriteIcon
'
),
TrackPlaylistIcon
:
()
=>
import
(
/* webpackChunkName: "auth-audio" */
'
@/components/playlists/TrackPlaylistIcon
'
),
draggable
:
()
=>
import
(
/* webpackChunkName: "draggable" */
'
vuedraggable
'
)
},
data
()
{
return
{
...
...
@@ -232,14 +230,13 @@ export default {
}
},
mounted
()
{
let
self
=
this
this
.
focusTrap
=
createFocusTrap
(
this
.
$el
,
{
allowOutsideClick
:
()
=>
{
return
true
}})
this
.
focusTrap
=
createFocusTrap
(
this
.
$el
,
{
allowOutsideClick
:
()
=>
{
return
true
}
})
this
.
focusTrap
.
activate
()
this
.
$nextTick
(()
=>
{
setTimeout
(()
=>
{
this
.
scrollToCurrent
()
// delay is to let transition work
},
400
)
;
},
400
)
})
},
computed
:
{
...
...
@@ -256,18 +253,18 @@ export default {
queue
:
state
=>
state
.
queue
}),
...
mapGetters
({
currentTrack
:
"
queue/currentTrack
"
,
hasNext
:
"
queue/hasNext
"
,
emptyQueue
:
"
queue/isEmpty
"
,
durationFormatted
:
"
player/durationFormatted
"
,
currentTimeFormatted
:
"
player/currentTimeFormatted
"
,
progress
:
"
player/progress
"
currentTrack
:
'
queue/currentTrack
'
,
hasNext
:
'
queue/hasNext
'
,
emptyQueue
:
'
queue/isEmpty
'
,
durationFormatted
:
'
player/durationFormatted
'
,
currentTimeFormatted
:
'
player/currentTimeFormatted
'
,
progress
:
'
player/progress
'
}),
tracks
:
{
get
()
{
get
()
{
return
this
.
$store
.
state
.
queue
.
tracks
},
set
(
value
)
{
set
(
value
)
{
this
.
tracksChangeBuffer
=
value
}
},
...
...
@@ -276,11 +273,11 @@ export default {
queue
:
this
.
$pgettext
(
'
*/*/*
'
,
'
Queue
'
),
duration
:
this
.
$pgettext
(
'
*/*/*
'
,
'
Duration
'
),
addArtistContentFilter
:
this
.
$pgettext
(
'
Sidebar/Player/Icon.Tooltip/Verb
'
,
'
Hide content from this artist…
'
),
restart
:
this
.
$pgettext
(
'
*/*/*
'
,
'
Restart track
'
)
,
restart
:
this
.
$pgettext
(
'
*/*/*
'
,
'
Restart track
'
)
}
},
timeLeft
()
{
le
t
seconds
=
lodash
.
sum
(
cons
t
seconds
=
lodash
.
sum
(
this
.
queue
.
tracks
.
slice
(
this
.
queue
.
currentIndex
).
map
((
t
)
=>
{
return
(
t
.
uploads
||
[]).
map
((
u
)
=>
{
return
u
.
duration
||
0
...
...
@@ -294,7 +291,7 @@ export default {
return
this
.
volume
},
set
(
v
)
{
this
.
$store
.
commit
(
"
player/volume
"
,
v
)
this
.
$store
.
commit
(
'
player/volume
'
,
v
)
}
},
playerFocused
()
{
...
...
@@ -303,58 +300,57 @@ export default {
},
methods
:
{
...
mapActions
({
cleanTrack
:
"
queue/cleanTrack
"
,
mute
:
"
player/mute
"
,
unmute
:
"
player/unmute
"
,
clean
:
"
queue/clean
"
,
toggleMute
:
"
player/toggleMute
"
,
resumePlayback
:
"
player/resumePlayback
"
,
pausePlayback
:
"
player/pausePlayback
"
,
cleanTrack
:
'
queue/cleanTrack
'
,
mute
:
'
player/mute
'
,
unmute
:
'
player/unmute
'
,
clean
:
'
queue/clean
'
,
toggleMute
:
'
player/toggleMute
'
,
resumePlayback
:
'
player/resumePlayback
'
,
pausePlayback
:
'
player/pausePlayback
'
}),
reorder
:
function
(
event
)
{
this
.
$store
.
commit
(
"
queue/reorder
"
,
{
reorder
:
function
(
event
)
{
this
.
$store
.
commit
(
'
queue/reorder
'
,
{
tracks
:
this
.
tracksChangeBuffer
,
oldIndex
:
event
.
oldIndex
,
newIndex
:
event
.
newIndex
})
},
scrollToCurrent
()
{
le
t
current
=
$
(
this
.
$el
).
find
(
'
.queue-item.active
'
)[
0
]
scrollToCurrent
()
{
cons
t
current
=
$
(
this
.
$el
).
find
(
'
.queue-item.active
'
)[
0
]
if
(
!
current
)
{
return
}
const
elementRect
=
current
.
getBoundingClientRect
()
;
const
absoluteElementTop
=
elementRect
.
top
+
window
.
pageYOffset
;
const
middle
=
absoluteElementTop
-
(
window
.
innerHeight
/
2
)
;
window
.
scrollTo
({
top
:
middle
,
behaviour
:
'
smooth
'
})
;
const
elementRect
=
current
.
getBoundingClientRect
()
const
absoluteElementTop
=
elementRect
.
top
+
window
.
pageYOffset
const
middle
=
absoluteElementTop
-
(
window
.
innerHeight
/
2
)
window
.
scrollTo
({
top
:
middle
,
behaviour
:
'
smooth
'
})
},
touchProgress
(
e
)
{
let
time
let
target
=
this
.
$refs
.
progress
time
=
(
e
.
layerX
/
target
.
offsetWidth
)
*
this
.
duration
touchProgress
(
e
)
{
const
target
=
this
.
$refs
.
progress
const
time
=
(
e
.
layerX
/
target
.
offsetWidth
)
*
this
.
duration
this
.
$emit
(
'
touch-progress
'
,
time
)
},
shuffle
()
{
le
t
disabled
=
this
.
queue
.
tracks
.
length
===
0
shuffle
()
{
cons
t
disabled
=
this
.
queue
.
tracks
.
length
===
0
if
(
this
.
isShuffling
||
disabled
)
{
return
}
le
t
self
=
this
le
t
msg
=
this
.
$pgettext
(
'
Content/Queue/Message
'
,
"
Queue shuffled!
"
)
cons
t
self
=
this
cons
t
msg
=
this
.
$pgettext
(
'
Content/Queue/Message
'
,
'
Queue shuffled!
'
)
this
.
isShuffling
=
true
setTimeout
(()
=>
{
self
.
$store
.
dispatch
(
"
queue/shuffle
"
,
()
=>
{
self
.
$store
.
dispatch
(
'
queue/shuffle
'
,
()
=>
{
self
.
isShuffling
=
false
self
.
$store
.
commit
(
"
ui/addMessage
"
,
{
self
.
$store
.
commit
(
'
ui/addMessage
'
,
{
content
:
msg
,
date
:
new
Date
()
})
})
},
100
)
}
,
}
},
watch
:
{
"
$store.state.ui.queueFocused
"
:
{
'
$store.state.ui.queueFocused
'
:
{
handler
(
v
)
{
if
(
v
===
'
queue
'
)
{
this
.
$nextTick
(()
=>
{
...
...
@@ -369,7 +365,7 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
scrollToCurrent
()
})
}
,
}
},
'
$store.state.queue.tracks
'
:
{
handler
(
v
)
{
...
...
@@ -379,7 +375,7 @@ export default {
},
immediate
:
true
},
"
$route.fullPath
"
()
{
'
$route.fullPath
'
()
{
this
.
$store
.
commit
(
'
ui/queueFocused
'
,
null
)
}
}
...
...
front/src/components/audio/Player.vue
View file @
5a74d1d3
This diff is collapsed.
Click to expand it.
front/src/store/player.js
View file @
5a74d1d3
...
...
@@ -92,86 +92,85 @@ export default {
}
},
actions
:
{
incrementVolume
({
commit
,
state
},
value
)
{
incrementVolume
({
commit
,
state
},
value
)
{
commit
(
'
volume
'
,
state
.
volume
+
value
)
},
stop
({
commit
})
{
stop
({
commit
})
{
commit
(
'
errored
'
,
false
)
commit
(
'
resetErrorCount
'
)
},
togglePlayback
({
commit
,
state
,
dispatch
})
{
togglePlayback
({
commit
,
state
,
dispatch
})
{
commit
(
'
playing
'
,
!
state
.
playing
)
if
(
state
.
errored
&&
state
.
errorCount
<
state
.
maxConsecutiveErrors
)
{
setTimeout
(()
=>
{
if
(
state
.
playing
)
{
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
}
},
3000
)
}
},
resumePlayback
({
commit
,
state
,
dispatch
})
{
resumePlayback
({
commit
,
state
,
dispatch
})
{
commit
(
'
playing
'
,
true
)
if
(
state
.
errored
&&
state
.
errorCount
<
state
.
maxConsecutiveErrors
)
{
setTimeout
(()
=>
{
if
(
state
.
playing
)
{
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
}
},
3000
)
}
},
pausePlayback
({
commit
})
{
pausePlayback
({
commit
})
{
commit
(
'
playing
'
,
false
)
},
toggleMute
({
commit
,
state
})
{
toggleMute
({
commit
,
state
})
{
if
(
state
.
volume
>
0
)
{
commit
(
'
tempVolume
'
,
state
.
volume
)
commit
(
'
volume
'
,
0
)
}
else
{
}
else
{
commit
(
'
volume
'
,
state
.
tempVolume
)
}
},
trackListened
({
commit
,
rootState
},
track
)
{
trackListened
({
commit
,
rootState
},
track
)
{
if
(
!
rootState
.
auth
.
authenticated
)
{
return
}
return
axios
.
post
(
'
history/listenings/
'
,
{
'
track
'
:
track
.
id
}).
then
((
response
)
=>
{},
(
response
)
=>
{
return
axios
.
post
(
'
history/listenings/
'
,
{
track
:
track
.
id
}).
then
((
response
)
=>
{},
(
response
)
=>
{
logger
.
default
.
error
(
'
Could not record track in history
'
)
})
},
trackEnded
({
commit
,
dispatch
,
rootState
},
track
)
{
le
t
queueState
=
rootState
.
queue
trackEnded
({
commit
,
dispatch
,
rootState
},
track
)
{
cons
t
queueState
=
rootState
.
queue
if
(
queueState
.
currentIndex
===
queueState
.
tracks
.
length
-
1
)
{
// we've reached last track of queue, trigger a reload
// from radio if any
dispatch
(
'
radios/populateQueue
'
,
null
,
{
root
:
true
})
dispatch
(
'
radios/populateQueue
'
,
null
,
{
root
:
true
})
}
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
if
(
queueState
.
ended
)
{
// Reset playback
commit
(
'
playing
'
,
false
)
dispatch
(
'
updateProgress
'
,
0
)
}
},
trackErrored
({
commit
,
dispatch
,
state
})
{
trackErrored
({
commit
,
dispatch
,
state
})
{
commit
(
'
errored
'
,
true
)
commit
(
'
incrementErrorCount
'
)
if
(
state
.
errorCount
<
state
.
maxConsecutiveErrors
)
{
setTimeout
(()
=>
{
if
(
state
.
playing
)
{
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
dispatch
(
'
queue/next
'
,
null
,
{
root
:
true
})
}
},
3000
)
}
},
updateProgress
({
commit
},
t
)
{
updateProgress
({
commit
},
t
)
{
commit
(
'
currentTime
'
,
t
)
},
mute
({
commit
,
state
})
{
mute
({
commit
,
state
})
{
commit
(
'
tempVolume
'
,
state
.
volume
)
commit
(
'
volume
'
,
0
)
},
unmute
({
commit
,
state
})
{
unmute
({
commit
,
state
})
{
commit
(
'
volume
'
,
state
.
tempVolume
)
}
}
...
...
Write
Preview
Supports
Markdown
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