Explorar el Código

:recycle: just a little more cleaning up

tags/0.9.0
j hace 5 años
padre
commit
a3ab427cb1
Se han modificado 2 ficheros con 18 adiciones y 16 borrados
  1. 16
    14
      vue-theme/src/pages/list.vue
  2. 2
    2
      vue-theme/src/pages/single.vue

+ 16
- 14
vue-theme/src/pages/list.vue Ver fichero

@@ -31,15 +31,11 @@ import sidebar from '@/components/sidebars/sidebar'
31 31
 import { convertTitleCase, typeFromRoute, sortTypes } from '@/utils/helpers'
32 32
 
33 33
 export default {
34
+    components: { sidebar },
34 35
     props: {
35
-        sidebar: {
36
-            type: Boolean
37
-        },
38
-        sortBy: {
39
-            type: String
40
-        }
36
+        sidebar: { type: Boolean },
37
+        sortBy: { type: String }
41 38
     },
42
-    components: { sidebar },
43 39
     computed: {
44 40
         ...mapGetters({
45 41
             allPages: 'allPages',
@@ -66,15 +62,21 @@ export default {
66 62
         },
67 63
         posts() {
68 64
             let type = convertTitleCase(this.type)
69
-            
70
-            // We're override the API to sort by date
71
-            // because items are returned by ID
65
+            if(!type) return
66
+
67
+            /**
68
+             * We override the API to sort by date
69
+             * because items are returned by ID so
70
+             * we need to resort it by date
71
+             */ 
72 72
             let unsortedOfType = Object.values(this[`all${type}`])
73
-            let sortedByRecent = unsortedOfType.sort((postA, postB) => {
74
-                return new Date(postB.date) - new Date(postA.date)
75
-            })
73
+            let sortedByRecent = unsortedOfType.sort((postA, postB) => new Date(postB.date) - new Date(postA.date))
76 74
             
77
-            // !: Sorting of this[`all${type}`] is controlled by API
75
+            /**
76
+             * Sorting of this[`all${type}`] is also controlled by API
77
+             * so if a sortBy is specified we return it sorted or
78
+             * we fail over to sorted by date
79
+             */
78 80
             return this.sortBy ? this[`all${type}`] : sortedByRecent
79 81
         },
80 82
     },

+ 2
- 2
vue-theme/src/pages/single.vue Ver fichero

@@ -39,10 +39,10 @@ import gallery from '@/components/gallery/'
39 39
 import { convertTitleCase, typeFromRoute } from '@/utils/helpers'
40 40
 
41 41
 export default {
42
+    components: { sidebar, gallery },
42 43
     props: {
43 44
         sidebar: { type: Boolean }
44 45
     },
45
-    components: { sidebar, gallery },
46 46
     data() {
47 47
         return {
48 48
             // Gallery control
@@ -152,7 +152,7 @@ export default {
152 152
          * !: posts watcher fires when this finishes
153 153
          */
154 154
         let type = convertTitleCase(this.type)
155
-        if(!this[`all${type}Loaded`]) {
155
+        if(!this[`all${type}Loaded`] && type) {
156 156
             // console.log('Retrieving...', type)
157 157
             this.$store.dispatch(`getAll${type}`)
158 158
         }

Loading…
Cancelar
Guardar