Просмотр исходного кода

:sparkles: breaking out title push func

tags/0.9.0
J 4 лет назад
Родитель
Сommit
e7bac43bac
1 измененных файлов: 10 добавлений и 13 удалений
  1. 10
    13
      vue-theme/src/store/modules/artist.js

+ 10
- 13
vue-theme/src/store/modules/artist.js Просмотреть файл

@@ -36,31 +36,28 @@ const _arrangeByMaterial = artistsList => {
36 36
 
37 37
 let seen = 0
38 38
 let hasTitle = []
39
+const storeTitle = letter => {
40
+    if(hasTitle.includes(letter)) return
41
+    flatPacked.push({ slug: letter, title: letter, inbetween: true })
42
+    hasTitle.push(letter)
43
+}
39 44
 const _arrangeByAlpha = artistsList => {
40 45
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
41 46
     const flatPacked = []
42 47
     artistsList.forEach((artist, i) => {
43 48
         const lastWord = artist.slug.split('-').filter(c => c).pop()
44
-        const firstCharaOfLastWord = lastWord[0]
45 49
         const firstCharaOfSortWord = artist.sortname ? artist.sortname[0] : 'z'
46
-        const charaIndex = alphabet.indexOf(firstCharaOfLastWord) < alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(firstCharaOfLastWord) : alphabet.indexOf(firstCharaOfSortWord)
50
+        const charaIndex = alphabet.indexOf(lastWord[0]) < alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(lastWord[0]) : alphabet.indexOf(firstCharaOfSortWord)
47 51
         
48
-        console.log('chara loading:', charaIndex)
49
-        // The first artist you've seen in this batch
52
+        // The first artist you've seen in THIS BATCH
50 53
         if(i == 0) {
51 54
             seen = charaIndex
52
-            flatPacked.push({ slug: alphabet[seen], title: alphabet[seen], inbetween: true })
53
-            hasTitle.push(alphabet[seen])
55
+            storeTitle(alphabet[seen])
54 56
         }
55
-
56 57
         if (charaIndex == seen + 1) {
57 58
             seen++
58
-            if(seen > alphabet.length) { seen = 0 }
59
-            
60
-            if(!hasTitle.includes(alphabet[seen])) {
61
-                flatPacked.push({ slug: alphabet[seen], title: alphabet[seen], inbetween: true })
62
-                hasTitle.push(alphabet[seen])
63
-            }
59
+            if(seen > alphabet.length) seen = 0
60
+            storeTitle(alphabet[seen])
64 61
         }
65 62
         flatPacked.push(artist)
66 63
     })

Загрузка…
Отмена
Сохранить