浏览代码

:recycle: adding route watch for JUST sort changes with same post type

tags/0.9.0
J 4 年前
父节点
当前提交
919e3e584a
共有 1 个文件被更改,包括 16 次插入2 次删除
  1. 16
    2
      vue-theme/src/pages/list.vue

+ 16
- 2
vue-theme/src/pages/list.vue 查看文件

@@ -183,8 +183,6 @@ export default {
183 183
             try {
184 184
                 if(!footerEl) throw `cannot unset intersection handler missing el: ${footerEl}`
185 185
                 if(!this.observer) throw `cannot unset intersection handler missing observer: ${this.observer}`
186
-                
187
-                console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
188 186
                 this.observer.unobserve(footerEl)
189 187
                 this.observer.disconnect()
190 188
             } catch (error) {
@@ -211,10 +209,26 @@ export default {
211 209
     watch: {
212 210
         // This only fires navigating from
213 211
         // a list page, to another list page
212
+        // and the post type has changed
214 213
         type(newType, oldType) {
215 214
             if(!postTypes.includes(newType)) return console.warn('type not found...')
216 215
 
217 216
             this.clearAndInitPostList('watcher')
217
+        },
218
+        // Only fire if the sort type has changed
219
+        // and the post type is the same
220
+        $route(to, from) {
221
+            const toPathSortBy = to.sortBy ? to.sortBy : to.fullPath
222
+                .split('/')
223
+                .filter(p => p)
224
+                .pop()
225
+            const fromPathSortBy = from.sortBy ? from.sortBy : from.fullPath
226
+                .split('/')
227
+                .filter(p => p)
228
+                .pop()
229
+            if(toPathSortBy != fromPathSortBy) {
230
+                this.clearAndInitPostList('watcher')
231
+            } 
218 232
         }
219 233
     },
220 234
     mounted() {

正在加载...
取消
保存