|
|
@@ -79,6 +79,20 @@ export default {
|
|
79
|
79
|
}
|
|
80
|
80
|
},
|
|
81
|
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
|
96
|
clearAllPosts() {
|
|
83
|
97
|
if(!this.type) return console.error(`type: ${this.type}...`)
|
|
84
|
98
|
const uppercaseType = this.type.toUpperCase() + 'S'
|
|
|
@@ -91,23 +105,9 @@ export default {
|
|
91
|
105
|
|
|
92
|
106
|
this.loadingFetched = true
|
|
93
|
107
|
// console.warn(`loading page ${this.page + 1} of ${type} posts: ${this.page * this.perPage + 1} to ${(this.page + 1) * this.perPage}`)
|
|
94
|
|
-
|
|
95
|
108
|
this.page++
|
|
96
|
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
|
112
|
async getPosts() {
|
|
113
|
113
|
let dispatchAction = `getMore${this.pType}`
|
|
|
@@ -123,7 +123,7 @@ export default {
|
|
123
|
123
|
params.sortType = this.type == 'episode' ? null : params.sortType
|
|
124
|
124
|
}
|
|
125
|
125
|
|
|
126
|
|
- let res = null
|
|
|
126
|
+ let res = []
|
|
127
|
127
|
// We always grab all pages on hero init so no need to do it here
|
|
128
|
128
|
if(this.pType && this.keepFetching && this.type != 'page') {
|
|
129
|
129
|
res = await this.$store.dispatch(dispatchAction, params)
|
|
|
@@ -131,10 +131,10 @@ export default {
|
|
131
|
131
|
|
|
132
|
132
|
// Stop trying to load more posts
|
|
133
|
133
|
if(res && !res.length || getAllClause) {
|
|
134
|
|
- console.warn(`empty response for ${this.type}:`, res)
|
|
135
|
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
|
139
|
async getPageForType(type) {
|
|
140
|
140
|
await this._getAll('page', this.$store)
|
|
|
@@ -206,7 +206,12 @@ export default {
|
|
206
|
206
|
// a list page, to another list page
|
|
207
|
207
|
// and the post type has changed
|
|
208
|
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
|
215
|
this.clearAndInitPostList('type watcher')
|
|
211
|
216
|
},
|
|
212
|
217
|
// Only fire if the sort type has changed
|