Explorar el Código

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

tags/0.9.0
J hace 4 años
padre
commit
2561689906

+ 6
- 0
vue-theme/src/pages/list.vue Ver fichero

104
 
104
 
105
             if(shouldClear) {
105
             if(shouldClear) {
106
                 this.$store.commit(`CLEAR_${this.pType.toUpperCase()}`)
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
             try {
115
             try {

+ 10
- 10
vue-theme/src/store/modules/arrangements.js Ver fichero

3
 const _insertInBetweens = bySort => {
3
 const _insertInBetweens = bySort => {
4
     const postListWithInBetweens = []
4
     const postListWithInBetweens = []
5
     Object.keys(bySort).forEach(term => {
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
         bySort[term].forEach(post => postListWithInBetweens.push(post))
13
         bySort[term].forEach(post => postListWithInBetweens.push(post))
12
     })
14
     })
13
     return postListWithInBetweens
15
     return postListWithInBetweens
40
     return flatPacked
42
     return flatPacked
41
 }
43
 }
42
 
44
 
43
-let seenTitles = []
44
-const _arrangeByAlpha = postsList => {
45
+const _arrangeByAlpha = (postsList, seenTitles) => {
45
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
46
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
46
     const flatPacked = []
47
     const flatPacked = []
47
     
48
     
60
         storeTitle(alphabet[charaIndex])
61
         storeTitle(alphabet[charaIndex])
61
         flatPacked.push(post)
62
         flatPacked.push(post)
62
     })
63
     })
63
-    seenTitles = []
64
     return flatPacked
64
     return flatPacked
65
 }
65
 }
66
 
66
 
75
     return flatPacked
75
     return flatPacked
76
 }
76
 }
77
 
77
 
78
-const repackBySort = (postsList, sortedBy) => {
78
+const repackBySort = (postsList, sortedBy, seenTitles) => {
79
     let repacked = postsList
79
     let repacked = postsList
80
     if(sortedBy == sortTypes.material) {
80
     if(sortedBy == sortTypes.material) {
81
         repacked = _arrangeByMaterial(postsList)
81
         repacked = _arrangeByMaterial(postsList)
84
     } else if(sortedBy == sortTypes.subtype) {
84
     } else if(sortedBy == sortTypes.subtype) {
85
         repacked = _arrangeByType(postsList)
85
         repacked = _arrangeByType(postsList)
86
     } else if(sortedBy == sortTypes.alpha) {
86
     } else if(sortedBy == sortTypes.alpha) {
87
-        repacked = _arrangeByAlpha(postsList)
87
+        repacked = _arrangeByAlpha(postsList, seenTitles)
88
     }
88
     }
89
     return repacked
89
     return repacked
90
 }
90
 }

+ 2
- 1
vue-theme/src/store/modules/artist.js Ver fichero

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

Loading…
Cancelar
Guardar