소스 검색

:recycle: simplifying singlee watcher | addressing #125

tags/0.9.0
J 4 년 전
부모
커밋
52ef76a28e
2개의 변경된 파일10개의 추가작업 그리고 23개의 파일을 삭제
  1. 2
    6
      vue-theme/src/pages/single.vue
  2. 8
    17
      vue-theme/src/store/modules/artist.js

+ 2
- 6
vue-theme/src/pages/single.vue 파일 보기

@@ -223,12 +223,8 @@ export default {
223 223
     watch: {
224 224
         slug(newSlug, oldSlug) {
225 225
             // ONLY load post data when navigating TO a single page
226
-            if(newSlug && !oldSlug) {
227
-                this._clearHero(this.$store)
228
-                this.loadPostData()
229
-            }
230
-            // ONLY load post data when navigating TO a single page from a single page
231
-            if(newSlug && oldSlug) {
226
+            // OR when navigating TO a single page from a single page
227
+            if(newSlug && !oldSlug || newSlug && oldSlug) {
232 228
                 this._clearHero(this.$store)
233 229
                 this.loadPostData()
234 230
             }

+ 8
- 17
vue-theme/src/store/modules/artist.js 파일 보기

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

Loading…
취소
저장