Преглед на файлове

:recycle: ignore presorted types to let the route watcher handle it

tags/0.9.0
J преди 4 години
родител
ревизия
5949b7699d
променени са 1 файла, в които са добавени 24 реда и са изтрити 19 реда
  1. 24
    19
      vue-theme/src/pages/list.vue

+ 24
- 19
vue-theme/src/pages/list.vue Целия файл

79
         }
79
         }
80
     },
80
     },
81
     methods: {
81
     methods: {
82
+        _getSortBy() {
83
+            return this.sortBy
84
+                ? this.sortBy
85
+                : sortFromRoute(this.$route)
86
+        },
87
+        _getDispatchParams(perPage) {
88
+            return {
89
+                sortType: this._getSortBy(),
90
+                params: {
91
+                    limit: perPage ? perPage : this.perPage,
92
+                    page: this.page
93
+                }
94
+            }
95
+        },
82
         clearAllPosts() {
96
         clearAllPosts() {
83
             if(!this.type) return console.error(`type: ${this.type}...`)
97
             if(!this.type) return console.error(`type: ${this.type}...`)
84
             const uppercaseType = this.type.toUpperCase() + 'S'
98
             const uppercaseType = this.type.toUpperCase() + 'S'
91
 
105
 
92
             this.loadingFetched = true
106
             this.loadingFetched = true
93
             // console.warn(`loading page ${this.page + 1} of ${type} posts: ${this.page * this.perPage + 1} to ${(this.page + 1) * this.perPage}`)
107
             // console.warn(`loading page ${this.page + 1} of ${type} posts: ${this.page * this.perPage + 1} to ${(this.page + 1) * this.perPage}`)
94
-
95
             this.page++
108
             this.page++
96
             await this.getPosts()
109
             await this.getPosts()
97
-        },
98
-        _getSortBy() {
99
-            return this.sortBy
100
-                ? this.sortBy
101
-                : sortFromRoute(this.$route)
102
-        },
103
-        _getDispatchParams(perPage) {
104
-            return {
105
-                sortType: this._getSortBy(),
106
-                params: {
107
-                    limit: perPage ? perPage : this.perPage,
108
-                    page: this.page
109
-                }
110
-            }
110
+            this.loadingFetched = false
111
         },
111
         },
112
         async getPosts() {
112
         async getPosts() {
113
             let dispatchAction = `getMore${this.pType}`
113
             let dispatchAction = `getMore${this.pType}`
123
                 params.sortType = this.type == 'episode' ? null : params.sortType
123
                 params.sortType = this.type == 'episode' ? null : params.sortType
124
             }
124
             }
125
 
125
 
126
-            let res = null
126
+            let res = []
127
             // We always grab all pages on hero init so no need to do it here
127
             // We always grab all pages on hero init so no need to do it here
128
             if(this.pType && this.keepFetching && this.type != 'page') {
128
             if(this.pType && this.keepFetching && this.type != 'page') {
129
                 res = await this.$store.dispatch(dispatchAction, params)
129
                 res = await this.$store.dispatch(dispatchAction, params)
131
 
131
 
132
             // Stop trying to load more posts
132
             // Stop trying to load more posts
133
             if(res && !res.length || getAllClause) {
133
             if(res && !res.length || getAllClause) {
134
-                console.warn(`empty response for ${this.type}:`, res)
135
                 this.keepFetching = false
134
                 this.keepFetching = false
135
+                if(!res.length) console.warn(`Empty response for ${this.type}:`, res.length)
136
+                if(getAllClause) console.warn(`Fetched all responses for ${this.type}:`, res.length)
136
             }
137
             }
137
-            this.loadingFetched = false
138
         },
138
         },
139
         async getPageForType(type) {
139
         async getPageForType(type) {
140
             await this._getAll('page', this.$store)
140
             await this._getAll('page', this.$store)
206
         // a list page, to another list page
206
         // a list page, to another list page
207
         // and the post type has changed
207
         // and the post type has changed
208
         type(newType, oldType) {
208
         type(newType, oldType) {
209
-            if(!postTypes.includes(newType)) return console.warn('type not found...')
209
+            if(!postTypes.includes(newType)) return console.warn('type not valid...')
210
+
211
+            // !:Ignore these default sorted types and let the route watcher deal with it
212
+            const ignore = ['event', 'exhibition', 'post']
213
+            if(ignore.includes(this.type)) return
214
+
210
             this.clearAndInitPostList('type watcher')
215
             this.clearAndInitPostList('type watcher')
211
         },
216
         },
212
         // Only fire if the sort type has changed
217
         // Only fire if the sort type has changed

Loading…
Отказ
Запис