|
|
@@ -33,7 +33,7 @@ import card from '@/components/card'
|
|
33
|
33
|
import sidebar from '@/components/sidebars/sidebar'
|
|
34
|
34
|
import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
|
|
35
|
35
|
|
|
36
|
|
-import { postTypes, sortTypes, convertTitleCase, typeFromRoute } from '@/utils/helpers'
|
|
|
36
|
+import { postTypes, sortTypes, convertTitleCase, typeFromRoute, sortFromRoute } from '@/utils/helpers'
|
|
37
|
37
|
|
|
38
|
38
|
const TIMEOUT = 1
|
|
39
|
39
|
const INTERSECT_SELECTOR = '.page--list > article footer'
|
|
|
@@ -98,10 +98,7 @@ export default {
|
|
98
|
98
|
_getSortBy() {
|
|
99
|
99
|
return this.sortBy
|
|
100
|
100
|
? this.sortBy
|
|
101
|
|
- : this.$route.path
|
|
102
|
|
- .split('/')
|
|
103
|
|
- .filter(p => p)
|
|
104
|
|
- .pop()
|
|
|
101
|
+ : sortFromRoute(this.$route)
|
|
105
|
102
|
},
|
|
106
|
103
|
_getDispatchParams(perPage) {
|
|
107
|
104
|
return {
|
|
|
@@ -210,23 +207,18 @@ export default {
|
|
210
|
207
|
// and the post type has changed
|
|
211
|
208
|
type(newType, oldType) {
|
|
212
|
209
|
if(!postTypes.includes(newType)) return console.warn('type not found...')
|
|
213
|
|
-
|
|
214
|
210
|
this.clearAndInitPostList('type watcher')
|
|
215
|
211
|
},
|
|
216
|
212
|
// Only fire if the sort type has changed
|
|
217
|
213
|
// and the post type is the same
|
|
|
214
|
+ // and both sorts are valid
|
|
218
|
215
|
$route(to, from) {
|
|
219
|
|
- const findSortBy = route => {
|
|
220
|
|
- return route.sortBy ? route.sortBy : route.fullPath
|
|
221
|
|
- .split('/')
|
|
222
|
|
- .filter(p => p)
|
|
223
|
|
- .pop()
|
|
224
|
|
- }
|
|
|
216
|
+ const validSorts = Object.values(sortTypes)
|
|
225
|
217
|
if (
|
|
226
|
|
- findSortBy(to) != findSortBy(from) &&
|
|
227
|
218
|
typeFromRoute(to) == typeFromRoute(from) &&
|
|
228
|
|
- // Post slug sometimes appears as a sort
|
|
229
|
|
- sortTypes.includes(findSortBy(to)) && sortTypes.includes(findSortBy(from))
|
|
|
219
|
+ sortFromRoute(to) != sortFromRoute(from) &&
|
|
|
220
|
+ // Post slug sometimes appears as a sort so we check it against known sorts
|
|
|
221
|
+ validSorts.includes(sortFromRoute(to)) && validSorts.includes(sortFromRoute(from))
|
|
230
|
222
|
) {
|
|
231
|
223
|
this.clearAndInitPostList('$route watcher')
|
|
232
|
224
|
}
|