|
|
@@ -74,7 +74,8 @@ export default {
|
|
74
|
74
|
return this[`all${this.pType}`]
|
|
75
|
75
|
},
|
|
76
|
76
|
isWide() {
|
|
77
|
|
- return this.type == 'exhibition' || this.type == 'event'
|
|
|
77
|
+ const wide = ['exhibition', 'event']
|
|
|
78
|
+ return wide.includes(this.type)
|
|
78
|
79
|
}
|
|
79
|
80
|
},
|
|
80
|
81
|
methods: {
|
|
|
@@ -85,8 +86,7 @@ export default {
|
|
85
|
86
|
this.$store.commit(`${uppercaseType}_LOADED`)
|
|
86
|
87
|
},
|
|
87
|
88
|
async loadMorePosts() {
|
|
88
|
|
- const type = typeFromRoute(this.$route)
|
|
89
|
|
- if(!type) return console.warn(`type: ${type} not found...`)
|
|
|
89
|
+ if(!this.type) return console.warn(`this.type: ${type} not found...`)
|
|
90
|
90
|
if(!this.keepFetching) return console.warn('nothing left to fetch...')
|
|
91
|
91
|
|
|
92
|
92
|
this.loadingFetched = true
|
|
|
@@ -117,7 +117,8 @@ export default {
|
|
117
|
117
|
let params = this._getDispatchParams()
|
|
118
|
118
|
|
|
119
|
119
|
// For episodes, or material sort we grab EVERYTHING
|
|
120
|
|
- if(this.type == 'episode' || this.type == 'artist' && this._getSortBy() == sortTypes.material) {
|
|
|
120
|
+ const getAllClause = this.type == 'episode' || this.type == 'artist' && this._getSortBy() == sortTypes.material
|
|
|
121
|
+ if(getAllClause) {
|
|
121
|
122
|
dispatchAction = `getAll${this.pType}`
|
|
122
|
123
|
params = this._getDispatchParams(-1)
|
|
123
|
124
|
|
|
|
@@ -132,8 +133,7 @@ export default {
|
|
132
|
133
|
}
|
|
133
|
134
|
|
|
134
|
135
|
// Stop trying to load more posts
|
|
135
|
|
- console.log('res :', res)
|
|
136
|
|
- if(res && !res.length) {
|
|
|
136
|
+ if(res && !res.length || getAllClause) {
|
|
137
|
137
|
console.warn(`empty response for ${this.type}:`, res)
|
|
138
|
138
|
this.keepFetching = false
|
|
139
|
139
|
}
|
|
|
@@ -158,10 +158,14 @@ export default {
|
|
158
|
158
|
},
|
|
159
|
159
|
setIntersectionLoader() {
|
|
160
|
160
|
if(!this.type) return console.error('cannot setup intersection handler for undefined type')
|
|
161
|
|
- console.log('Setting interesection loader...')
|
|
162
|
161
|
|
|
163
|
|
- const footerEl = document.querySelector(INTERSECT_SELECTOR)
|
|
164
|
|
- if(!footerEl) return
|
|
|
162
|
+ // KeepFetching is UNSET for certain post types and sort types in `loadMorePosts()`
|
|
|
163
|
+ if(!this.keepFetching) return console.warn('cannot setup intersection handler keepFetching is set false')
|
|
|
164
|
+
|
|
|
165
|
+ console.warn('Setting interesection loader...')
|
|
|
166
|
+
|
|
|
167
|
+ // Always unset and reset the intersection loader
|
|
|
168
|
+ const footerEl = this.unsetIntersectionLoader()
|
|
165
|
169
|
|
|
166
|
170
|
const onIntersect = (entries, observer) => {
|
|
167
|
171
|
entries.forEach(entry => {
|
|
|
@@ -178,14 +182,19 @@ export default {
|
|
178
|
182
|
console.log(this.observer)
|
|
179
|
183
|
},
|
|
180
|
184
|
unsetIntersectionLoader() {
|
|
181
|
|
- const footerEl = document.querySelector(INTERSECT_SELECTOR)
|
|
182
|
|
- if(!footerEl || !this.observer) return
|
|
183
|
|
-
|
|
184
|
|
- console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
|
|
185
|
|
- this.observer.unobserve(footerEl)
|
|
186
|
|
- this.observer.disconnect()
|
|
|
185
|
+ try {
|
|
|
186
|
+ const footerEl = document.querySelector(INTERSECT_SELECTOR)
|
|
|
187
|
+ console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
|
|
|
188
|
+ this.observer.unobserve(footerEl)
|
|
|
189
|
+ this.observer.disconnect()
|
|
|
190
|
+ } catch (err) {
|
|
|
191
|
+ console.error(`cannot unset intersection handler. Have you tried setting the el: ${footerEl} or observer: ${this.observer} ?\n`)
|
|
|
192
|
+ console.error(`More info: ${err}`)
|
|
|
193
|
+ }
|
|
|
194
|
+ return footerEl
|
|
187
|
195
|
},
|
|
188
|
196
|
clearAndInitPostList() {
|
|
|
197
|
+ console.log('---')
|
|
189
|
198
|
this.page = 0
|
|
190
|
199
|
this.keepFetching = true
|
|
191
|
200
|
|
|
|
@@ -196,11 +205,7 @@ export default {
|
|
196
|
205
|
this.clearAllPosts()
|
|
197
|
206
|
this.loadMorePosts()
|
|
198
|
207
|
|
|
199
|
|
- // Always unset and reset the intersection loader
|
|
200
|
|
- this.unsetIntersectionLoader()
|
|
201
|
|
- if(this._getSortBy() != sortTypes.material) {
|
|
202
|
|
- this.setIntersectionLoader()
|
|
203
|
|
- }
|
|
|
208
|
+ this.setIntersectionLoader()
|
|
204
|
209
|
}
|
|
205
|
210
|
},
|
|
206
|
211
|
watch: {
|
|
|
@@ -214,8 +219,8 @@ export default {
|
|
214
|
219
|
}
|
|
215
|
220
|
},
|
|
216
|
221
|
mounted() {
|
|
217
|
|
- console.log('init from mounted...')
|
|
218
|
222
|
// This only fires navigating from a single page, to a list page
|
|
|
223
|
+ console.log('init from mounted...')
|
|
219
|
224
|
this.clearAndInitPostList()
|
|
220
|
225
|
},
|
|
221
|
226
|
beforeDestroy() {
|