Parcourir la source

:recycle: guarding against blank type for getMorePosts

tags/0.9.0
J il y a 4 ans
Parent
révision
774660814b
2 fichiers modifiés avec 11 ajouts et 6 suppressions
  1. 1
    1
      vue-theme/src/pages/list.vue
  2. 10
    5
      vue-theme/src/pages/single.vue

+ 1
- 1
vue-theme/src/pages/list.vue Voir le fichier

@@ -123,7 +123,7 @@ export default {
123 123
                     )
124 124
                 }
125 125
             // Add to existing
126
-            } else if (!clear) {
126
+            } else if (!clear && this.getMoreName) {
127 127
                 this.$store.dispatch(
128 128
                     this.getMoreName,
129 129
                     { sortType: sort, params }

+ 10
- 5
vue-theme/src/pages/single.vue Voir le fichier

@@ -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)

Chargement…
Annuler
Enregistrer