mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Refactor
This commit is contained in:
parent
d27f7aa7c3
commit
84d523d240
7 changed files with 7 additions and 15 deletions
|
@ -160,7 +160,7 @@ export default {
|
|||
}
|
||||
|
||||
this.sortKey = key
|
||||
this.order = 0 - this.order
|
||||
this.order *= -1
|
||||
this.sortingByAlbum = Array.isArray(this.sortKey) && this.sortKey[0] === 'song.album.name'
|
||||
this.sortingByArtist = Array.isArray(this.sortKey) && this.sortKey[0] === 'song.album.artist.name'
|
||||
this.songRows = orderBy(this.songRows, this.sortKey, this.order)
|
||||
|
|
|
@ -2,9 +2,7 @@ import localStore from 'local-storage'
|
|||
|
||||
export const ls = {
|
||||
get (key, defaultVal = null) {
|
||||
const val = localStore(key)
|
||||
|
||||
return val || defaultVal
|
||||
return localStore(key) || defaultVal
|
||||
},
|
||||
|
||||
set (key, val) {
|
||||
|
|
|
@ -369,6 +369,7 @@ export const playback = {
|
|||
playAllByArtist (artist, shuffled = true) {
|
||||
if (!shuffled) {
|
||||
this.queueAndPlay(orderBy(artist.songs, 'album_id', 'track'))
|
||||
return
|
||||
}
|
||||
|
||||
this.queueAndPlay(artist.songs, true)
|
||||
|
|
|
@ -24,7 +24,6 @@ export const albumStore = {
|
|||
// While we're doing so, for each album, we get its length
|
||||
// and keep a back reference to the artist too.
|
||||
each(artist.albums, album => this.setupAlbum(album, artist))
|
||||
|
||||
return albums.concat(artist.albums)
|
||||
}, [])
|
||||
|
||||
|
@ -103,7 +102,7 @@ export const albumStore = {
|
|||
addSongsIntoAlbum (album, songs) {
|
||||
songs = [].concat(songs)
|
||||
|
||||
album.songs = union(album.songs ? album.songs : [], songs)
|
||||
album.songs = union(album.songs || [], songs)
|
||||
|
||||
each(songs, song => {
|
||||
song.album_id = album.id
|
||||
|
|
|
@ -26,7 +26,6 @@ export const artistStore = {
|
|||
|
||||
// Traverse through artists array to get the cover and number of songs for each.
|
||||
each(this.all, artist => this.setupArtist(artist))
|
||||
|
||||
albumStore.init(this.all)
|
||||
},
|
||||
|
||||
|
@ -121,7 +120,7 @@ export const artistStore = {
|
|||
addAlbumsIntoArtist (artist, albums) {
|
||||
albums = [].concat(albums)
|
||||
|
||||
artist.albums = union(artist.albums ? artist.albums : [], albums)
|
||||
artist.albums = union(artist.albums || [], albums)
|
||||
|
||||
each(albums, album => {
|
||||
album.artist_id = artist.id
|
||||
|
|
|
@ -37,10 +37,7 @@ export const songStore = {
|
|||
// Iterate through the albums. With each, add its songs into our master song list.
|
||||
// While doing so, we populate some other information into the songs as well.
|
||||
this.all = albums.reduce((songs, album) => {
|
||||
each(album.songs, song => {
|
||||
this.setupSong(song, album)
|
||||
})
|
||||
|
||||
each(album.songs, song => this.setupSong(song, album))
|
||||
return songs.concat(album.songs)
|
||||
}, [])
|
||||
|
||||
|
|
|
@ -66,9 +66,7 @@ const event = {
|
|||
if (arguments.length === 2) {
|
||||
this.bus.$on(arguments[0], arguments[1])
|
||||
} else {
|
||||
each(Object.keys(arguments[0]), key => {
|
||||
this.bus.$on(key, arguments[0][key])
|
||||
})
|
||||
each(Object.keys(arguments[0]), key => this.bus.$on(key, arguments[0][key]))
|
||||
}
|
||||
|
||||
return this
|
||||
|
|
Loading…
Reference in a new issue