瀏覽代碼

:bug: repacking titles with vuex state again | pass state to refactored helpers | #160

tags/0.9.0
J 4 年之前
父節點
當前提交
2561689906
共有 3 個文件被更改,包括 18 次插入11 次删除
  1. 6
    0
      vue-theme/src/pages/list.vue
  2. 10
    10
      vue-theme/src/store/modules/arrangements.js
  3. 2
    1
      vue-theme/src/store/modules/artist.js

+ 6
- 0
vue-theme/src/pages/list.vue 查看文件

@@ -104,6 +104,12 @@ export default {
104 104
 
105 105
             if(shouldClear) {
106 106
                 this.$store.commit(`CLEAR_${this.pType.toUpperCase()}`)
107
+                
108
+                // Clear any state needed to track title inbetweens
109
+                const hasInbetweens = ['artist']
110
+                if(hasInbetweens.includes(this.type)) {
111
+                    this.$store.commit(`CLEAR_${this.pType.toUpperCase()}_SEEN`)
112
+                }
107 113
             }
108 114
 
109 115
             try {

+ 10
- 10
vue-theme/src/store/modules/arrangements.js 查看文件

@@ -3,11 +3,13 @@ import { sortTypes } from '../../utils/helpers'
3 3
 const _insertInBetweens = bySort => {
4 4
     const postListWithInBetweens = []
5 5
     Object.keys(bySort).forEach(term => {
6
-        postListWithInBetweens.push({ 
7
-            slug: term,
8
-            title: term,
9
-            inbetween: true
10
-        })
6
+        if(term) {
7
+            postListWithInBetweens.push({ 
8
+                slug: term,
9
+                title: term,
10
+                inbetween: true
11
+            })
12
+        }
11 13
         bySort[term].forEach(post => postListWithInBetweens.push(post))
12 14
     })
13 15
     return postListWithInBetweens
@@ -40,8 +42,7 @@ const _arrangeByType = postsList => {
40 42
     return flatPacked
41 43
 }
42 44
 
43
-let seenTitles = []
44
-const _arrangeByAlpha = postsList => {
45
+const _arrangeByAlpha = (postsList, seenTitles) => {
45 46
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
46 47
     const flatPacked = []
47 48
     
@@ -60,7 +61,6 @@ const _arrangeByAlpha = postsList => {
60 61
         storeTitle(alphabet[charaIndex])
61 62
         flatPacked.push(post)
62 63
     })
63
-    seenTitles = []
64 64
     return flatPacked
65 65
 }
66 66
 
@@ -75,7 +75,7 @@ const _arrangeByEpisode = postsList => {
75 75
     return flatPacked
76 76
 }
77 77
 
78
-const repackBySort = (postsList, sortedBy) => {
78
+const repackBySort = (postsList, sortedBy, seenTitles) => {
79 79
     let repacked = postsList
80 80
     if(sortedBy == sortTypes.material) {
81 81
         repacked = _arrangeByMaterial(postsList)
@@ -84,7 +84,7 @@ const repackBySort = (postsList, sortedBy) => {
84 84
     } else if(sortedBy == sortTypes.subtype) {
85 85
         repacked = _arrangeByType(postsList)
86 86
     } else if(sortedBy == sortTypes.alpha) {
87
-        repacked = _arrangeByAlpha(postsList)
87
+        repacked = _arrangeByAlpha(postsList, seenTitles)
88 88
     }
89 89
     return repacked
90 90
 }

+ 2
- 1
vue-theme/src/store/modules/artist.js 查看文件

@@ -6,6 +6,7 @@ const state = {
6 6
     all: [],
7 7
     loaded: false,
8 8
     singleArtist: null,
9
+    seenTitles: []
9 10
 }
10 11
 
11 12
 const getters = {
@@ -29,7 +30,7 @@ const actions = {
29 30
         const storeFetch = (artists => {
30 31
             let repacked = artists
31 32
             if(sortType == sortTypes.alpha) {
32
-                repacked = repackBySort(artists, sortType)
33
+                repacked = repackBySort(artists, sortType, state.seenTitles)
33 34
             }
34 35
             commit('ADD_TO_FETCHED_ARTISTS', { artists: repacked })
35 36
             commit('ARTISTS_LOADED', true)

Loading…
取消
儲存