|
|
@@ -2,7 +2,7 @@
|
|
2
|
2
|
.page--single.f-col.between
|
|
3
|
3
|
gallery(v-if="activeGalleryIndex >= 0" :activeImageIndex="activeImageIndex" :images="imagesInGallery" @close="closeGallery")
|
|
4
|
4
|
|
|
5
|
|
- article.w-max(v-if="!singlePost || loading")
|
|
|
5
|
+ article.w-max.f-grow.shadow(v-if="!singlePost || loading")
|
|
6
|
6
|
header
|
|
7
|
7
|
p loading...
|
|
8
|
8
|
article(v-else).w-max.f-grow.shadow
|
|
|
@@ -28,9 +28,9 @@
|
|
28
|
28
|
ul
|
|
29
|
29
|
li.f-row.between(v-for="artist in p2pPostsByType['artist']")
|
|
30
|
30
|
card(:content="artist" type="artist" :wide="true" :hide-type="true")
|
|
31
|
|
-
|
|
|
31
|
+
|
|
32
|
32
|
credits(v-if="type === 'episode' && singlePost" :post="singlePost")
|
|
33
|
|
-
|
|
|
33
|
+
|
|
34
|
34
|
//- end of article icon
|
|
35
|
35
|
footer.f-col
|
|
36
|
36
|
img(src="../star.svg")
|
|
|
@@ -39,7 +39,6 @@
|
|
39
|
39
|
</template>
|
|
40
|
40
|
|
|
41
|
41
|
<script>
|
|
42
|
|
-import { mapGetters, mapState } from 'vuex'
|
|
43
|
42
|
import card from '@/components/card.vue'
|
|
44
|
43
|
import sidebar from '@/components/sidebars/sidebar'
|
|
45
|
44
|
import gallery from '@/components/gallery/'
|
|
|
@@ -56,7 +55,6 @@ export default {
|
|
56
|
55
|
components: { sidebar, gallery, credits, card, breadcrumb },
|
|
57
|
56
|
props: {
|
|
58
|
57
|
sidebar: { type: Boolean },
|
|
59
|
|
- id: { type: Number },
|
|
60
|
58
|
},
|
|
61
|
59
|
mixins: [postTypeGetters, scrollTop, heroUtils],
|
|
62
|
60
|
data() {
|
|
|
@@ -162,10 +160,10 @@ export default {
|
|
162
|
160
|
// _setHeroInfo(post) {} from mixin
|
|
163
|
161
|
// _clearHero(store) {} from mixin
|
|
164
|
162
|
/**
|
|
165
|
|
- * Everytime the posts object changes
|
|
|
163
|
+ * Everytime the post object changes
|
|
166
|
164
|
* we use this to set a new HERO
|
|
167
|
165
|
* in vuex
|
|
168
|
|
- * @param {object} posts
|
|
|
166
|
+ * @param {object} post
|
|
169
|
167
|
*/
|
|
170
|
168
|
checkAndSetHero(post) {
|
|
171
|
169
|
this._clearHero(this.$store)
|
|
|
@@ -182,30 +180,43 @@ export default {
|
|
182
|
180
|
},
|
|
183
|
181
|
|
|
184
|
182
|
async loadPostData() {
|
|
|
183
|
+ this.loading = true
|
|
185
|
184
|
/**
|
|
186
|
185
|
* Conditionally load based on post type
|
|
187
|
186
|
* which is derived from the route
|
|
188
|
187
|
*/
|
|
189
|
188
|
// modules are NOT plural because module key
|
|
190
|
189
|
if (!this.$store.state[this.type]) return
|
|
191
|
|
- let allPostsOfType = this.$store.state[this.type].all
|
|
|
190
|
+ const allPostsOfTypeInStore = this.$store.state[this.type].all
|
|
192
|
191
|
|
|
193
|
192
|
/**
|
|
194
|
193
|
* Load posts if they're not already in state
|
|
195
|
194
|
*/
|
|
196
|
195
|
// Find the single post from api if it's not already in state
|
|
197
|
196
|
// Then add it to our list
|
|
198
|
|
- let singlePostData = allPostsOfType.filter(
|
|
|
197
|
+ let singlePostData = allPostsOfTypeInStore.filter(
|
|
199
|
198
|
post => post.slug == this.$route.params.slug,
|
|
200
|
199
|
)[0]
|
|
201
|
200
|
|
|
202
|
|
- if (!singlePostData) return console.error('could not get single post data...')
|
|
203
|
|
-
|
|
204
|
|
- // NOT plural
|
|
|
201
|
+ // Look if it exists before you try and load everything!
|
|
|
202
|
+ if (!singlePostData) {
|
|
|
203
|
+ console.error('Could not find single post in store; Fetching everything...')
|
|
|
204
|
+ const res = await this.$store.dispatch(
|
|
|
205
|
+ `getAll${convertTitleCase(this.type)}s`,
|
|
|
206
|
+ { sortType: null, params: null}
|
|
|
207
|
+ )
|
|
|
208
|
+ singlePostData = res.filter(
|
|
|
209
|
+ post => post.slug == this.$route.params.slug,
|
|
|
210
|
+ )[0]
|
|
|
211
|
+ }
|
|
|
212
|
+
|
|
|
213
|
+ /**
|
|
|
214
|
+ * At the point we MUST have singlePostData
|
|
|
215
|
+ */
|
|
205
|
216
|
this.checkAndSetHero(singlePostData)
|
|
206
|
217
|
await this.$store.dispatch(
|
|
207
|
218
|
`getSingle${convertTitleCase(this.type)}`,
|
|
208
|
|
- this.id,
|
|
|
219
|
+ singlePostData.id,
|
|
209
|
220
|
)
|
|
210
|
221
|
this.loading = false
|
|
211
|
222
|
},
|