Przeglądaj źródła

:bug: fix for sorting on route change

tags/0.9.0
J 5 lat temu
rodzic
commit
5ce49268b7
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8
    3
      vue-theme/src/pages/list.vue

+ 8
- 3
vue-theme/src/pages/list.vue Wyświetl plik

70
         setHeroAndGetPosts() {
70
         setHeroAndGetPosts() {
71
             let type = convertTitleCase(this.type)
71
             let type = convertTitleCase(this.type)
72
 
72
 
73
+            let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
74
+            
75
+            console.log('trying to sort by:, sort')
76
+
73
             // Seperate sorting from post slugs
77
             // Seperate sorting from post slugs
74
-            if(!this.sortBy || Object.values(sortTypes).indexOf(this.sortBy) >= 0) { 
78
+            if(sort && Object.values(sortTypes).includes(sort)) { 
75
                 // Don't dispatch if there's no type
79
                 // Don't dispatch if there's no type
76
                 if(this.type) {
80
                 if(this.type) {
77
-                    this.$store.dispatch(this.dispatchName, this.sortBy)
81
+                    this.$store.dispatch(this.dispatchName, sort)
78
                 }
82
                 }
79
             }
83
             }
80
             if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
84
             if(this.$store.state.hero.url !== type) this.$store.commit('SET_HERO', type)
83
     watch: {
87
     watch: {
84
         $route(to, from){
88
         $route(to, from){
85
             let type = convertTitleCase(this.type)
89
             let type = convertTitleCase(this.type)
86
-            if(!this[`all${type}Loaded`]) this.setHeroAndGetPosts()
90
+            let sort = this.sortBy ? this.sortBy : to.path.split('/').pop()
91
+            if(!this[`all${type}Loaded`] || sort) this.setHeroAndGetPosts()
87
         }
92
         }
88
     },
93
     },
89
     created() {
94
     created() {

Ładowanie…
Anuluj
Zapisz