瀏覽代碼

: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
         },
70
         },
71
     },
71
     },
72
     methods: {
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
         loadMorePosts() {
78
         loadMorePosts() {
74
             // console.log(this.$route)
79
             // console.log(this.$route)
75
             const type = typeFromRoute(this.$route)
80
             const type = typeFromRoute(this.$route)
78
 
83
 
79
             console.warn(`loading more ${type} posts...`)
84
             console.warn(`loading more ${type} posts...`)
80
             this.page++
85
             this.page++
81
-            this.getPosts({ clear: false })
86
+            this.getPosts()
82
         },
87
         },
83
         _getSortBy() {
88
         _getSortBy() {
84
             return this.sortBy
89
             return this.sortBy
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
             // pType sometimes is undefined so need to dispatch and
107
             // pType sometimes is undefined so need to dispatch and
103
             let res = null
108
             let res = null
104
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
109
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
171
     created() {
176
     created() {
172
         console.log('--- List page ---')
177
         console.log('--- List page ---')
173
         // Fires when loading from home
178
         // Fires when loading from home
179
+        // Clear any preloaded posts (from home, etc.)
180
+        this.clearAllPosts()
174
         this.loadMorePosts()
181
         this.loadMorePosts()
182
+
175
         this.setIntersectionLoader()
183
         this.setIntersectionLoader()
176
     }
184
     }
177
 }
185
 }

Loading…
取消
儲存