Kaynağa Gözat

:sparkles: repacking by subtype for artist module

tags/0.9.0
J 4 yıl önce
ebeveyn
işleme
feac472c74
1 değiştirilmiş dosya ile 20 ekleme ve 1 silme
  1. 20
    1
      vue-theme/src/store/modules/artist.js

+ 20
- 1
vue-theme/src/store/modules/artist.js Dosyayı Görüntüle

@@ -37,6 +37,24 @@ const _arrangeByMaterial = artistsList => {
37 37
     return flatPacked
38 38
 }
39 39
 
40
+const _arrangeByType = artistsList => {
41
+    const byType = {}
42
+    artistsList.forEach(artist => {
43
+        const subtypes = artist.subtypes
44
+        subtypes.forEach(type => {
45
+            if(!byType[type]) byType[type] = []
46
+            byType[type].push(artist)
47
+        })
48
+    })
49
+    const flatPacked = []
50
+    Object.keys(byType).forEach(type => {
51
+        flatPacked.push({ slug: type, title: type, inbetween: true })
52
+        byType[type].forEach(artist => flatPacked.push(artist))
53
+    })
54
+    console.log('flatPacked :', flatPacked)
55
+    return flatPacked
56
+}
57
+
40 58
 const _arrangeByAlpha = artistsList => {
41 59
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
42 60
     const flatPacked = []
@@ -71,7 +89,6 @@ const _arrangeByEpisode = artistsList => {
71 89
         flatPacked.push({ slug: episode, title: episode, inbetween: true })
72 90
         byEpisode[episode].forEach(artist => flatPacked.push(artist))
73 91
     })
74
-    console.log('flatPacked :', flatPacked)
75 92
     return flatPacked
76 93
 }
77 94
 
@@ -85,6 +102,8 @@ const actions = {
85 102
                 repacked = _arrangeByMaterial(artists)
86 103
             } else if(sortType == sortTypes.episode) {
87 104
                 repacked = _arrangeByEpisode(artists)
105
+            } else if(sortType == sortTypes.subtype) {
106
+                repacked = _arrangeByType(artists)
88 107
             }
89 108
             commit('STORE_FETCHED_ARTISTS', { artists: repacked })
90 109
             commit('ARTISTS_LOADED', true)

Loading…
İptal
Kaydet