|
|
@@ -59,6 +59,23 @@ const _arrangeByAlpha = artistsList => {
|
|
59
|
59
|
return flatPacked
|
|
60
|
60
|
}
|
|
61
|
61
|
|
|
|
62
|
+const _arrangeByEpisode = artistsList => {
|
|
|
63
|
+ const byEpisode = {}
|
|
|
64
|
+ artistsList.forEach(artist => {
|
|
|
65
|
+ const relatedEpisode = artist.related_episode
|
|
|
66
|
+ if(!Object.keys(byEpisode).includes(relatedEpisode)) {
|
|
|
67
|
+ byEpisode[relatedEpisode] = []
|
|
|
68
|
+ }
|
|
|
69
|
+ byEpisode[relatedEpisode].push(artist)
|
|
|
70
|
+ })
|
|
|
71
|
+ const flatPacked = []
|
|
|
72
|
+ Object.keys(byEpisode).forEach(episode => {
|
|
|
73
|
+ flatPacked.push({ slug: byEpisode, title: byEpisode, inbetween: true })
|
|
|
74
|
+ byEpisode[episode].forEach(artist => flatPacked.push(artist))
|
|
|
75
|
+ })
|
|
|
76
|
+ return flatPacked
|
|
|
77
|
+}
|
|
|
78
|
+
|
|
62
|
79
|
const actions = {
|
|
63
|
80
|
getAllArtists({ commit }, { sortType, params }) {
|
|
64
|
81
|
commit('CLEAR_ARTISTS')
|
|
|
@@ -67,6 +84,8 @@ const actions = {
|
|
67
|
84
|
let repacked = artists
|
|
68
|
85
|
if(sortType == sortTypes.material) {
|
|
69
|
86
|
repacked = _arrangeByMaterial(artists)
|
|
|
87
|
+ } else if(sortType == sortTypes.episode) {
|
|
|
88
|
+ repacked = _arrangeByEpisode(artists)
|
|
70
|
89
|
}
|
|
71
|
90
|
commit('STORE_FETCHED_ARTISTS', { artists: repacked })
|
|
72
|
91
|
commit('ARTISTS_LOADED', true)
|