|
|
@@ -209,14 +209,19 @@ export default {
|
|
209
|
209
|
*/
|
|
210
|
210
|
// Find the single post from api if it's not already in state
|
|
211
|
211
|
// Then add it to our list
|
|
212
|
|
-
|
|
213
|
|
- const res = await this.$store.dispatch(`getAll${type}`, { sortType: null, params: null})
|
|
214
|
|
- allPostsOfType = res
|
|
215
|
|
-
|
|
216
|
|
- const singlePostData = allPostsOfType.filter(
|
|
|
212
|
+ let singlePostData = allPostsOfType.filter(
|
|
217
|
213
|
post => post.slug == this.$route.params.slug,
|
|
218
|
214
|
)[0]
|
|
219
|
215
|
|
|
|
216
|
+ // Look if it exists before you try and load everything!
|
|
|
217
|
+ if(!singlePostData) {
|
|
|
218
|
+ const res = await this.$store.dispatch(`getAll${type}`, { sortType: null, params: null})
|
|
|
219
|
+ allPostsOfType = res
|
|
|
220
|
+ singlePostData = allPostsOfType.filter(
|
|
|
221
|
+ post => post.slug == this.$route.params.slug,
|
|
|
222
|
+ )[0]
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
220
|
225
|
if (!singlePostData) return
|
|
221
|
226
|
|
|
222
|
227
|
this.checkAndSetHero(singlePostData)
|