Kaynağa Gözat

:bug: tracking seen title inbetween state in vuex | clearing from list

tags/0.9.0
J 4 yıl önce
ebeveyn
işleme
5b38683502

+ 10
- 4
vue-theme/src/pages/list.vue Dosyayı Görüntüle

87
     },
87
     },
88
     methods: {
88
     methods: {
89
         async loadMorePosts(shouldClear) {
89
         async loadMorePosts(shouldClear) {
90
+            
90
             if(!this.keepFetching) return console.warn('Nothing left to fetch...')
91
             if(!this.keepFetching) return console.warn('Nothing left to fetch...')
91
 
92
 
92
             const getPosts = async  (params, dispatchType) => {
93
             const getPosts = async  (params, dispatchType) => {
93
                 if(!this.type) throw `post type: ${this.type} not found...`
94
                 if(!this.type) throw `post type: ${this.type} not found...`
94
-                console.log('$route :', this.$route)
95
+                
95
                 // We always grab all pages on hero init so no need to do it here
96
                 // We always grab all pages on hero init so no need to do it here
96
                 return this.pType && this.type != 'page' ? await this.$store.dispatch(
97
                 return this.pType && this.type != 'page' ? await this.$store.dispatch(
97
                     `get${dispatchType}${this.pType}`,
98
                     `get${dispatchType}${this.pType}`,
99
                 ) : []
100
                 ) : []
100
             }
101
             }
101
 
102
 
102
-            if(shouldClear) this.$store.commit(`CLEAR_${this.pType.toUpperCase()}`)
103
-            console.log('loadMore $route :', this.$route)
103
+            if(shouldClear) {
104
+                this.$store.commit(`CLEAR_${this.pType.toUpperCase()}`)
105
+                
106
+                // Clear any state needed to track title inbetweens
107
+                this.$store.commit(`CLEAR_${this.pType.toUpperCase()}_SEEN`)
108
+            }
109
+
104
             try {
110
             try {
105
                 this.loadingFetched = true
111
                 this.loadingFetched = true
106
                 this.page++
112
                 this.page++
197
         // This only fires navigating from a non-list page > list page
203
         // This only fires navigating from a non-list page > list page
198
         this.initPostList()
204
         this.initPostList()
199
     },
205
     },
200
-    beforeDestroy() {
206
+    beforeUnmount() {
201
         this.unsetIntersectionLoader()
207
         this.unsetIntersectionLoader()
202
     }
208
     }
203
 }
209
 }

+ 8
- 4
vue-theme/src/store/modules/artist.js Dosyayı Görüntüle

5
     all: [],
5
     all: [],
6
     loaded: false,
6
     loaded: false,
7
     singleArtist: null,
7
     singleArtist: null,
8
+    seenTitles: []
8
 }
9
 }
9
 
10
 
10
 const getters = {
11
 const getters = {
36
     return flatPacked
37
     return flatPacked
37
 }
38
 }
38
 
39
 
39
-let seenTitles = []
40
 const _arrangeByAlpha = artistsList => {
40
 const _arrangeByAlpha = artistsList => {
41
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
41
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
42
     const flatPacked = []
42
     const flatPacked = []
43
-
43
+    
44
     const storeTitle = letter => {
44
     const storeTitle = letter => {
45
-        if(seenTitles.includes(letter)) return
45
+        if(state.seenTitles.includes(letter)) return
46
         flatPacked.push({ slug: letter, title: letter, inbetween: true })
46
         flatPacked.push({ slug: letter, title: letter, inbetween: true })
47
-        seenTitles.push(letter)
47
+        state.seenTitles.push(letter)
48
     }
48
     }
49
 
49
 
50
     artistsList.forEach(artist => {
50
     artistsList.forEach(artist => {
74
         return api.getByType({ type: 'artist', sort: sortType, params, cb: storeFetch })
74
         return api.getByType({ type: 'artist', sort: sortType, params, cb: storeFetch })
75
     },
75
     },
76
     getMoreArtists({ commit }, { sortType, params }) {
76
     getMoreArtists({ commit }, { sortType, params }) {
77
+        commit('ARTISTS_LOADED', false)
77
         const storeFetch = (artists => {
78
         const storeFetch = (artists => {
78
             let repacked = artists
79
             let repacked = artists
79
             if(sortType == sortTypes.alpha) {
80
             if(sortType == sortTypes.alpha) {
108
     CLEAR_ARTISTS(state) {
109
     CLEAR_ARTISTS(state) {
109
         state.all = []
110
         state.all = []
110
     },
111
     },
112
+    CLEAR_ARTISTS_SEEN(state) {
113
+        state.seenTitles = []
114
+    },
111
     CLEAR_SINGLE_ARTISTS(state) {
115
     CLEAR_SINGLE_ARTISTS(state) {
112
         state.singleArtist = null
116
         state.singleArtist = null
113
     },
117
     },

+ 1
- 1
vue-theme/src/utils/api.js Dosyayı Görüntüle

23
 export default {
23
 export default {
24
     getByType({ type, sort, params, cb }) {
24
     getByType({ type, sort, params, cb }) {
25
         const query = constructQuery(params)
25
         const query = constructQuery(params)
26
-
27
         if (sort && Object.values(sortTypes).includes(sort)) {
26
         if (sort && Object.values(sortTypes).includes(sort)) {
27
+            console.log('---')
28
             return axios
28
             return axios
29
                 .get(SETTINGS.API_BASE_PATH + `sort/${type}/${sort}${query}`)
29
                 .get(SETTINGS.API_BASE_PATH + `sort/${type}/${sort}${query}`)
30
                 .then(response => {
30
                 .then(response => {

Loading…
İptal
Kaydet