瀏覽代碼

:recycle: clearing loaded posts for list pages

tags/0.9.0
J 4 年之前
父節點
當前提交
1a34ad56d7
共有 1 個檔案被更改,包括 11 行新增3 行删除
  1. 11
    3
      vue-theme/src/pages/list.vue

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

@@ -70,6 +70,11 @@ export default {
70 70
         },
71 71
     },
72 72
     methods: {
73
+        clearAllPosts() {
74
+            const uppercaseType = this.type.toUpperCase() + 's'
75
+            this.$store.commit(`CLEAR_${uppercaseType}`)
76
+            this.$store.commit(`${uppercaseType}_LOADED`)
77
+        },
73 78
         loadMorePosts() {
74 79
             // console.log(this.$route)
75 80
             const type = typeFromRoute(this.$route)
@@ -78,7 +83,7 @@ export default {
78 83
 
79 84
             console.warn(`loading more ${type} posts...`)
80 85
             this.page++
81
-            this.getPosts({ clear: false })
86
+            this.getPosts()
82 87
         },
83 88
         _getSortBy() {
84 89
             return this.sortBy
@@ -97,8 +102,8 @@ export default {
97 102
                 }
98 103
             }
99 104
         },
100
-        async getPosts({ clear }) {
101
-            const dispatchAction = clear ? `getAll${this.pType}` : `getMore${this.pType}`
105
+        async getPosts() {
106
+            const dispatchAction = `getMore${this.pType}`
102 107
             // pType sometimes is undefined so need to dispatch and
103 108
             let res = null
104 109
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
@@ -171,7 +176,10 @@ export default {
171 176
     created() {
172 177
         console.log('--- List page ---')
173 178
         // Fires when loading from home
179
+        // Clear any preloaded posts (from home, etc.)
180
+        this.clearAllPosts()
174 181
         this.loadMorePosts()
182
+
175 183
         this.setIntersectionLoader()
176 184
     }
177 185
 }

Loading…
取消
儲存