Browse Source

:recycle: fixing repack on get more alpha

tags/0.9.0
J 4 years ago
parent
commit
da418ef531
1 changed files with 13 additions and 5 deletions
  1. 13
    5
      vue-theme/src/store/modules/artist.js

+ 13
- 5
vue-theme/src/store/modules/artist.js View File

@@ -38,9 +38,16 @@ const _arrangeByAlpha = artistsList => {
38 38
     let seen = 0
39 39
     const alphabet = [...'abcdefghijklmnopqrstuvwxyz']
40 40
     const flatPacked = []
41
-    artistsList.forEach(artist => {
41
+    artistsList.forEach((artist, i) => {
42 42
         const lastWord = artist.slug.split('-').filter(c => c).pop()
43 43
         const firstCharaOfLastWord = lastWord[0]
44
+        
45
+        // The first artist you've seen in this batch
46
+        if(i == 0) {
47
+            seen = alphabet.indexOf[firstCharaOfLastWord]
48
+            flatPacked.push({ slug: alphabet[seen], title: alphabet[seen] })
49
+        }
50
+
44 51
         if (alphabet.indexOf(firstCharaOfLastWord) == seen + 1) {
45 52
             seen++
46 53
             flatPacked.push({ slug: alphabet[seen], title: alphabet[seen] })
@@ -59,9 +66,6 @@ const actions = {
59 66
             if(sortType == sortTypes.material) {
60 67
                 repacked = _arrangeByMaterial(artists)
61 68
             }
62
-            if(sortType == sortTypes.alpha) {
63
-                repacked = _arrangeByAlpha(artists)
64
-            }
65 69
             commit('STORE_FETCHED_ARTISTS', { artists: repacked })
66 70
             commit('ARTISTS_LOADED', true)
67 71
         })
@@ -69,7 +73,11 @@ const actions = {
69 73
     },
70 74
     getMoreArtists({ commit }, { sortType, params }) {
71 75
         const storeFetch = (artists => {
72
-            commit('ADD_TO_FETCHED_ARTISTS', { artists })
76
+            let repacked = artists
77
+            if(sortType == sortTypes.alpha) {
78
+                repacked = _arrangeByAlpha(artists)
79
+            }
80
+            commit('ADD_TO_FETCHED_ARTISTS', { artists: repacked })
73 81
             commit('ARTISTS_LOADED', true)
74 82
         })
75 83
         return api.getByType({ type: 'artist', sort: sortType, params, cb: storeFetch })

Loading…
Cancel
Save