浏览代码

:bug: fixing import for refactored hero functions

tags/0.9.0
J 4 年前
父节点
当前提交
ea566a868e
共有 2 个文件被更改,包括 15 次插入32 次删除
  1. 12
    11
      vue-theme/src/pages/list.vue
  2. 3
    21
      vue-theme/src/pages/single.vue

+ 12
- 11
vue-theme/src/pages/list.vue 查看文件

@@ -27,9 +27,9 @@
27 27
 import featuredImage from '@/components/featured-image'
28 28
 import card from '@/components/card'
29 29
 import sidebar from '@/components/sidebars/sidebar'
30
-import { postTypeGetters, scrollTop } from './mixin-post-types'
30
+import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
31 31
 
32
-import { convertTitleCase, typeFromRoute, sortTypes } from '@/utils/helpers'
32
+import { convertTitleCase, typeFromRoute } from '@/utils/helpers'
33 33
 
34 34
 const TIMEOUT = 1
35 35
 
@@ -77,30 +77,31 @@ export default {
77 77
             this.page++
78 78
             this.getPosts({ clear: false })
79 79
         },
80
-        async getPosts({ clear }) {
81
-            // Sorting
82
-            let sort = this.sortBy
80
+        _getSortBy() {
81
+            return this.sortBy
83 82
                 ? this.sortBy
84 83
                 : this.$route.path
85 84
                       .split('/')
86 85
                       .filter(p => p)
87 86
                       .pop()
88
-
89
-            const dispatchParams = {
90
-                sortType: sort,
87
+        },
88
+        _getDispatchParams() {
89
+            return {
90
+                sortType: this._getSortBy(),
91 91
                 params: {
92 92
                     limit: this.perPage,
93 93
                     page: this.page
94 94
                 }
95 95
             }
96
+        },
97
+        async getPosts({ clear }) {
96 98
             const dispatchAction = clear ? `getAll${this.pType}` : `getMore${this.pType}`
97
-
98 99
             // pType sometimes is undefined so need to dispatch and
99 100
             // Episodes only needs load call
100 101
             let res = null
101 102
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
102
-                console.log('d:', dispatchAction, dispatchParams)
103
-                res = await this.$store.dispatch(dispatchAction, dispatchParams)
103
+                console.log('d:', dispatchAction, this._getDispatchParams())
104
+                res = await this.$store.dispatch(dispatchAction, this._getDispatchParams())
104 105
             }
105 106
 
106 107
             // Stop trying to load more posts

+ 3
- 21
vue-theme/src/pages/single.vue 查看文件

@@ -46,7 +46,7 @@ import gallery from '@/components/gallery/'
46 46
 import credits from '@/components/credits'
47 47
 import breadcrumb from '@/components/breadcrumb'
48 48
 
49
-import { postTypeGetters, stateHelper, scrollTop } from './mixin-post-types'
49
+import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
50 50
 
51 51
 import { convertTitleCase, dePluralize, typeFromRoute } from '@/utils/helpers'
52 52
 
@@ -168,7 +168,8 @@ export default {
168 168
          * @param {object} posts
169 169
          */
170 170
         checkAndSetHero(post) {
171
-            if (!post) return
171
+            this._clearHero(this.$store)
172
+            if (!post) return console.warn(`no post found`)
172 173
             this.$store.commit('SET_HERO', this._setHeroInfo(post))
173 174
         },
174 175
 
@@ -183,7 +184,6 @@ export default {
183 184
             /**
184 185
              * Conditionally load based on post type
185 186
              * which is derived from the route
186
-             * !: posts watcher fires when this finishes
187 187
              */
188 188
             // modules are NOT plural because module key
189 189
             if (!this.$store.state[this.type]) return
@@ -217,21 +217,8 @@ export default {
217 217
             )
218 218
             this.loading = false
219 219
         },
220
-
221
-        scrollTo(hashtag) {
222
-            setTimeout(() => {
223
-                location.href = hashtag
224
-            }, TIMEOUT)
225
-        },
226 220
     },
227 221
     watch: {
228
-        post(newVal, oldVal) {
229
-            // Prevent loading single post when
230
-            // navigating AWAY from the page
231
-            // if (!oldVal) {
232
-            //     this.checkAndSetHero(newVal)
233
-            // }
234
-        },
235 222
         $route(to, from) {
236 223
             // Only load post data when
237 224
             //  navigating TO a single page
@@ -242,11 +229,6 @@ export default {
242 229
             }
243 230
         },
244 231
     },
245
-    mounted() {
246
-        // if (this.$route.hash) {
247
-        //     setTimeout(() => this.scrollTo(this.$route.hash), TIMEOUT)
248
-        // }
249
-    },
250 232
     created() {
251 233
        this.loadPostData()
252 234
     },

正在加载...
取消
保存