|
|
@@ -21,8 +21,6 @@
|
|
21
|
21
|
//- Important: Do NOT remove this! Required for intersection observer
|
|
22
|
22
|
footer
|
|
23
|
23
|
p(v-if="loadingFetched") loading more {{ type }}...
|
|
24
|
|
- p(v-if="showMeta") {{ `${type} count: ${Object.values(posts).length}` }}
|
|
25
|
|
- p(v-if="showMeta") {{ `show sidebar: ${sidebar}` }}
|
|
26
|
24
|
|
|
27
|
25
|
sidebar(v-if="sidebar" :type="`${type}`" layout="list")
|
|
28
|
26
|
</template>
|
|
|
@@ -47,7 +45,6 @@ export default {
|
|
47
|
45
|
mixins: [postTypeGetters, scrollTop, heroUtils],
|
|
48
|
46
|
data() {
|
|
49
|
47
|
return {
|
|
50
|
|
- showMeta:false,
|
|
51
|
48
|
page: 0,
|
|
52
|
49
|
perPage: 21,
|
|
53
|
50
|
keepFetching: true,
|
|
|
@@ -56,37 +53,15 @@ export default {
|
|
56
|
53
|
}
|
|
57
|
54
|
},
|
|
58
|
55
|
computed: {
|
|
59
|
|
- grid() {
|
|
60
|
|
- return gridTypes.includes(this.type)
|
|
61
|
|
- },
|
|
62
|
|
- isWide() {
|
|
63
|
|
- return wideTypes.includes(this.type)
|
|
64
|
|
- },
|
|
65
|
|
- sidebar() {
|
|
66
|
|
- return !sansSidebarTypes.includes(this.type)
|
|
67
|
|
- },
|
|
68
|
|
- type() {
|
|
69
|
|
- // Checks for type and fixes Episodes route edge case
|
|
70
|
|
- return this.$route.params.type
|
|
71
|
|
- },
|
|
72
|
|
- sortBy() {
|
|
73
|
|
- return this.$route.params.sortBy
|
|
74
|
|
- },
|
|
75
|
|
- pType() {
|
|
76
|
|
- if(!this.type) return
|
|
77
|
|
- return `${convertTitleCase(this.type)}s`
|
|
78
|
|
- },
|
|
79
|
|
- loaded() {
|
|
80
|
|
- if (!this.pType) return
|
|
81
|
|
- return this[`all${this.pType}Loaded`]
|
|
82
|
|
- },
|
|
83
|
|
- posts() {
|
|
84
|
|
- if (!this.pType) return
|
|
85
|
|
- return this[`all${this.pType}`]
|
|
86
|
|
- },
|
|
87
|
|
- shouldLoadAllAtOnce() {
|
|
88
|
|
- return this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material
|
|
89
|
|
- }
|
|
|
56
|
+ grid: () => gridTypes.includes(this.type),
|
|
|
57
|
+ isWide: () => wideTypes.includes(this.type),
|
|
|
58
|
+ sidebar: () => !sansSidebarTypes.includes(this.type),
|
|
|
59
|
+ type: () => this.$route.params.type,
|
|
|
60
|
+ sortBy: () => this.$route.params.sortBy,
|
|
|
61
|
+ pType: () => `${convertTitleCase(this.type)}s`,
|
|
|
62
|
+ loaded: () => this[`all${this.pType}Loaded`],
|
|
|
63
|
+ posts: () => this[`all${this.pType}`],
|
|
|
64
|
+ shouldLoadAllAtOnce: () => this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material
|
|
90
|
65
|
},
|
|
91
|
66
|
methods: {
|
|
92
|
67
|
async loadMorePosts(shouldClear) {
|
|
|
@@ -96,7 +71,6 @@ export default {
|
|
96
|
71
|
try {
|
|
97
|
72
|
this.loadingFetched = true
|
|
98
|
73
|
this.page++
|
|
99
|
|
-
|
|
100
|
74
|
const res = await this.getPosts(
|
|
101
|
75
|
{
|
|
102
|
76
|
limit: this.shouldLoadAllAtOnce ? -1 : this.perPage,
|
|
|
@@ -104,9 +78,8 @@ export default {
|
|
104
|
78
|
},
|
|
105
|
79
|
this.shouldLoadAllAtOnce ? 'All' : 'More'
|
|
106
|
80
|
)
|
|
107
|
|
-
|
|
108
|
81
|
this.loadingFetched = false
|
|
109
|
|
-
|
|
|
82
|
+
|
|
110
|
83
|
// Stop trying to load more posts
|
|
111
|
84
|
if(res && !res.length || this.shouldLoadAllAtOnce) {
|
|
112
|
85
|
this.keepFetching = false
|
|
|
@@ -117,8 +90,8 @@ export default {
|
|
117
|
90
|
},
|
|
118
|
91
|
async getPosts(params, dispatchType) {
|
|
119
|
92
|
if(!this.type) throw `post type: ${this.type} not found...`
|
|
120
|
|
-
|
|
121
|
93
|
let res = []
|
|
|
94
|
+
|
|
122
|
95
|
// We always grab all pages on hero init so no need to do it here
|
|
123
|
96
|
if(this.pType && this.keepFetching && this.type != 'page') {
|
|
124
|
97
|
res = await this.$store.dispatch(
|
|
|
@@ -145,9 +118,7 @@ export default {
|
|
145
|
118
|
// Because the hero component will deal
|
|
146
|
119
|
// with how to render based on hero.url
|
|
147
|
120
|
this.$store.commit('SET_HERO', this._setHeroInfo(page))
|
|
148
|
|
- } catch (err) {
|
|
149
|
|
- console.error(err)
|
|
150
|
|
- }
|
|
|
121
|
+ } catch (err) { console.error(err) }
|
|
151
|
122
|
},
|
|
152
|
123
|
setIntersectionLoader() {
|
|
153
|
124
|
// KeepFetching is UNSET for certain post types and sort types in `loadMorePosts()`
|
|
|
@@ -186,9 +157,7 @@ export default {
|
|
186
|
157
|
}
|
|
187
|
158
|
},
|
|
188
|
159
|
watch: {
|
|
189
|
|
- // This only fires navigating from
|
|
190
|
|
- // a list page, to another list page
|
|
191
|
|
- // and the post type has changed
|
|
|
160
|
+ // This only fires navigating from a list page, to another list page
|
|
192
|
161
|
type(newType) {
|
|
193
|
162
|
if(!postTypes.includes(newType)) return console.warn('Type not valid...')
|
|
194
|
163
|
|