Просмотр исходного кода

:recycle: simplifying dispatch names

tags/0.9.0
J 4 лет назад
Родитель
Сommit
b2f10a9e9e
1 измененных файлов: 11 добавлений и 13 удалений
  1. 11
    13
      vue-theme/src/pages/list.vue

+ 11
- 13
vue-theme/src/pages/list.vue Просмотреть файл

@@ -53,14 +53,7 @@ export default {
53 53
             return typeFromRoute(this.$route)
54 54
         },
55 55
         pType() {
56
-            const plural = this.type + 's'
57
-            return convertTitleCase(plural)
58
-        },
59
-        dispatchName() {
60
-            return this.sortBy ? `getAll${this.pType.split('/')[0]}` : `getAll${this.pType}`
61
-        },
62
-        getMoreName() {
63
-            return this.sortBy ? `getMore${this.pType.split('/')[0]}` : `getMore${this.pType}`
56
+            return this.sortBy ? `${type.split('/')[0]}s` : `${type}s`
64 57
         },
65 58
         loaded() {
66 59
             if (!this.pType) return
@@ -92,18 +85,23 @@ export default {
92 85
                       .pop()
93 86
 
94 87
             let dispatchParams = { sortType: sort, params }
95
-            let dispatchAction = this.dispatchName
88
+            let dispatchAction = `getAll${this.pType}`
96 89
 
97
-            if(this.dispatchName && clear) {
90
+            if(dispatchAction && clear) {
98 91
                 if (this.type && ['event', 'exhibitions'].includes(this.type)) {
99 92
                     dispatchParams.sortType = sortTypes.currentAndUpcoming
100 93
                 }
101 94
             }
102 95
             // Add to existing except episodes
103
-            else if (!clear && this.getMoreName && this.type != 'episode') {
104
-                dispatchAction = this.getMoreName
96
+            else if (!clear && this.type != 'episode') {
97
+                dispatchAction = `getMore${this.pType}`
98
+            }
99
+            const res = this.$store.dispatch(dispatchAction, dispatchParams)
100
+            
101
+            console.log('responded:', res)
102
+            if(res.length < 1) {
103
+                console.warn('nothing left to get...')
105 104
             }
106
-            this.$store.dispatch(dispatchAction, dispatchParams)
107 105
         },
108 106
         clearHero() {
109 107
             this.$store.commit('SET_HERO', { url: null, heroType: null })

Загрузка…
Отмена
Сохранить