|
|
@@ -116,15 +116,18 @@ export default {
|
|
116
|
116
|
let dispatchAction = `getMore${this.pType}`
|
|
117
|
117
|
let params = this._getDispatchParams()
|
|
118
|
118
|
|
|
119
|
|
- // For episodes or material sort we grab EVERYTHING
|
|
|
119
|
+ // For episodes, or material sort we grab EVERYTHING
|
|
120
|
120
|
if(this.type == 'episode' || this.type == 'artist' && this._getSortBy() == sortTypes.material) {
|
|
121
|
121
|
dispatchAction = `getAll${this.pType}`
|
|
122
|
122
|
params = this._getDispatchParams(-1)
|
|
|
123
|
+
|
|
|
124
|
+ // Clear sortType if this is an episodes list
|
|
|
125
|
+ params.sortType = this.type == 'episode' ? null : params.sortType
|
|
123
|
126
|
}
|
|
124
|
127
|
|
|
125
|
|
- const ignore = ['getMorePages']
|
|
126
|
128
|
let res = null
|
|
127
|
|
- if(this.pType && !ignore.includes(dispatchAction) && this.keepFetching) {
|
|
|
129
|
+ // We always grab all pages on hero init so no need to do it here
|
|
|
130
|
+ if(this.pType && this.keepFetching && this.type != 'page') {
|
|
128
|
131
|
res = await this.$store.dispatch(dispatchAction, params)
|
|
129
|
132
|
}
|
|
130
|
133
|
|
|
|
@@ -135,22 +138,21 @@ export default {
|
|
135
|
138
|
}
|
|
136
|
139
|
this.loadingFetched = false
|
|
137
|
140
|
},
|
|
|
141
|
+ async getPageForType(type) {
|
|
|
142
|
+ await this._getAll('page', this.$store)
|
|
|
143
|
+ if(!this.allPages) return console.warn('no pages in state', this)
|
|
|
144
|
+ const page = this.allPages.filter(page => page.slug == `${type}s`)[0]
|
|
|
145
|
+ if(!page) return console.warn(`no page for ${type} found`)
|
|
|
146
|
+ return page
|
|
|
147
|
+ },
|
|
138
|
148
|
// _setHeroInfo(post) {} from mixin
|
|
139
|
149
|
// _clearHero(store) {} from mixin
|
|
140
|
150
|
async checkAndSetHero(type) {
|
|
141
|
151
|
this._clearHero(this.$store)
|
|
142
|
|
-
|
|
143
|
|
- await this._getAll('page', this.$store)
|
|
144
|
|
-
|
|
|
152
|
+ const page = await this.getPageForType(type)
|
|
145
|
153
|
// We always set a hero no matter what
|
|
146
|
154
|
// Because the hero component will deal
|
|
147
|
155
|
// with how to render based on hero.url
|
|
148
|
|
- if(!this.allPages) return console.warn('no pages in state', this)
|
|
149
|
|
- const page = this.allPages.filter(
|
|
150
|
|
- page => page.slug == `${type}s`,
|
|
151
|
|
- )[0]
|
|
152
|
|
- if(!page) return console.warn(`no page for ${type} found`)
|
|
153
|
|
-
|
|
154
|
156
|
this.$store.commit('SET_HERO', this._setHeroInfo(page))
|
|
155
|
157
|
},
|
|
156
|
158
|
setIntersectionLoader() {
|
|
|
@@ -163,9 +165,7 @@ export default {
|
|
163
|
165
|
const onIntersect = (entries, observer) => {
|
|
164
|
166
|
entries.forEach(entry => {
|
|
165
|
167
|
if (!entry.isIntersecting || this.loadingFetched) return
|
|
166
|
|
- setTimeout(() => {
|
|
167
|
|
- this.loadMorePosts()
|
|
168
|
|
- }, TIMEOUT)
|
|
|
168
|
+ setTimeout(() => this.loadMorePosts(), TIMEOUT)
|
|
169
|
169
|
})
|
|
170
|
170
|
}
|
|
171
|
171
|
this.observer = new IntersectionObserver(onIntersect, {
|
|
|
@@ -173,6 +173,8 @@ export default {
|
|
173
|
173
|
})
|
|
174
|
174
|
this.observer['_for_type'] = this.type
|
|
175
|
175
|
this.observer.observe(footerEl)
|
|
|
176
|
+ console.log('--- observer')
|
|
|
177
|
+ console.log(this.observer)
|
|
176
|
178
|
},
|
|
177
|
179
|
unsetIntersectionLoader() {
|
|
178
|
180
|
const footerEl = document.querySelector(INTERSECT_SELECTOR)
|
|
|
@@ -220,19 +222,8 @@ export default {
|
|
220
|
222
|
this.setIntersectionLoader()
|
|
221
|
223
|
}
|
|
222
|
224
|
|
|
223
|
|
- // Check if we changed sort method
|
|
224
|
|
- // from no sort to sorted
|
|
225
|
|
- // or sorted to no sort
|
|
226
|
|
- // or sort to a different sort(?)
|
|
227
|
|
- if(
|
|
228
|
|
- from.fullPath.includes(this.sortBy) ||
|
|
229
|
|
- (!to.fullPath.includes(this.sortBy) && !from.fullPath.includes(this.sortBy))
|
|
230
|
|
- ) {
|
|
231
|
|
- const ignore = ['event', 'exhibition', 'post']
|
|
232
|
|
- if(ignore.includes(this.type)) return
|
|
233
|
|
- console.log('init from $route watch...')
|
|
234
|
|
- this.clearAndInitPostList()
|
|
235
|
|
- }
|
|
|
225
|
+ console.log('init from $route watch...')
|
|
|
226
|
+ this.clearAndInitPostList()
|
|
236
|
227
|
}
|
|
237
|
228
|
},
|
|
238
|
229
|
mounted() {
|