Browse Source

:bug: fixed race condition in gallery parsing

tags/0.9.0
J 5 years ago
parent
commit
8b8b0ba07b

+ 13
- 10
vue-theme/src/pages/list.vue View File

@@ -29,7 +29,7 @@
29 29
 import { mapGetters } from 'vuex'
30 30
 import sidebar from '@/components/sidebars/sidebar'
31 31
 
32
-import { convertTitleCase, typeFromRoute } from '@/utils/helpers'
32
+import { convertTitleCase, typeFromRoute, sortTypes } from '@/utils/helpers'
33 33
 
34 34
 export default {
35 35
     props: {
@@ -81,8 +81,11 @@ export default {
81 81
 
82 82
             // Accounts for the sort-by in URL case 
83 83
             let dispatchName = this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
84
-            this.$store.dispatch(dispatchName, this.sortBy)
85 84
             
85
+            // Seperate sorting from post slugs
86
+            if(Object.values(sortTypes).indexOf(this.sortBy) >= 0) {
87
+                this.$store.dispatch(dispatchName, this.sortBy)
88
+            }
86 89
             if(this.$store.state.hero.url !== type) {
87 90
                 this.$store.commit('SET_HERO', type)
88 91
             }
@@ -93,17 +96,17 @@ export default {
93 96
         
94 97
         this.$store.dispatch(`getAll${type}`, this.sortBy)
95 98
         this.$store.commit('SET_HERO', type)
96
-        console.log(this.isGrid)
97 99
     }
98 100
 }
99 101
 </script>
100 102
 
101 103
 <style lang="postcss">
102
-article
103
-    .is-grid
104
-        display: flex
105
-        flex-direction: row
106
-        section
107
-            width: 33%
108
-
104
+.page--list
105
+    article
106
+        .is-grid
107
+            display: flex
108
+            flex-direction: row
109
+            flex-wrap: wrap
110
+            section
111
+                width: 33%
109 112
 </style>

+ 5
- 6
vue-theme/src/pages/single.vue View File

@@ -73,16 +73,15 @@ export default {
73 73
     },
74 74
     methods: {
75 75
         pageBlocks(posts) {
76
-            if(!posts || !posts[this.$route.params.slug]) return []
76
+            if(!posts || !posts[this.$route.params.slug] || !posts[this.$route.params.slug].blocks ) return []
77
+            
77 78
             return posts[this.$route.params.slug].blocks.map(block => {
78 79
                 if(block) return block
79 80
             })
80 81
         },
81 82
         checkForImages(posts) {
82 83
             if(Object.keys(posts).length == 0) return
83
-            console.log(posts)
84 84
             this.pageBlocks(posts).forEach(block => {
85
-                console.log(block)
86 85
                 const doc = new DOMParser().parseFromString(block, 'text/html')
87 86
                 const gallery = doc.querySelectorAll('.blocks-gallery-item img')
88 87
 
@@ -128,9 +127,9 @@ export default {
128 127
         }
129 128
     },
130 129
     created() {
131
-        if(!this.allLoaded) {
132
-            let type = convertTitleCase(this.$route.params.type)
133
-            console.log('Retrieving...', type)
130
+        let type = convertTitleCase(this.$route.params.type)
131
+        if(!this[`all{type}Loaded`]) {
132
+            // console.log('Retrieving...', type)
134 133
             this.$store.dispatch(`getAll${type}`)
135 134
         }
136 135
     }

+ 3
- 2
vue-theme/src/utils/api.js View File

@@ -7,12 +7,13 @@ const SETTINGS = {
7 7
 
8 8
 export default {
9 9
     getByType(type, sortType, cb) {
10
-        console.log('sortType:', sortType)
11 10
         if (sortType) {
12 11
             axios.get(SETTINGS.API_BASE_PATH + `sort/${type}/${sortType}`).then(response => {
13 12
                 cb(response.data)
14 13
             }).catch(e => { cb(e) })
15
-        } else {
14
+        }
15
+
16
+        else {
16 17
             axios.get(SETTINGS.API_BASE_PATH + `${type}`).then(response => {
17 18
                 cb(response.data)
18 19
             }).catch(e => { cb(e) })

+ 7
- 1
vue-theme/src/utils/helpers.js View File

@@ -6,4 +6,10 @@ const typeFromRoute = (route) => {
6 6
     return route.params.type ? route.params.type : route.fullPath.slice(1)
7 7
 }
8 8
 
9
-export { convertTitleCase, typeFromRoute }
9
+const sortTypes = {
10
+    alpha: 'by-alpha',
11
+    recent: 'by-recent',
12
+    material: 'by-material',
13
+}
14
+
15
+export { convertTitleCase, typeFromRoute, sortTypes }

Loading…
Cancel
Save