Bladeren bron

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

tags/0.9.0
J 4 jaren geleden
bovenliggende
commit
919e3e584a
1 gewijzigde bestanden met toevoegingen van 16 en 2 verwijderingen
  1. 16
    2
      vue-theme/src/pages/list.vue

+ 16
- 2
vue-theme/src/pages/list.vue Bestand weergeven

183
             try {
183
             try {
184
                 if(!footerEl) throw `cannot unset intersection handler missing el: ${footerEl}`
184
                 if(!footerEl) throw `cannot unset intersection handler missing el: ${footerEl}`
185
                 if(!this.observer) throw `cannot unset intersection handler missing observer: ${this.observer}`
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
                 this.observer.unobserve(footerEl)
186
                 this.observer.unobserve(footerEl)
189
                 this.observer.disconnect()
187
                 this.observer.disconnect()
190
             } catch (error) {
188
             } catch (error) {
211
     watch: {
209
     watch: {
212
         // This only fires navigating from
210
         // This only fires navigating from
213
         // a list page, to another list page
211
         // a list page, to another list page
212
+        // and the post type has changed
214
         type(newType, oldType) {
213
         type(newType, oldType) {
215
             if(!postTypes.includes(newType)) return console.warn('type not found...')
214
             if(!postTypes.includes(newType)) return console.warn('type not found...')
216
 
215
 
217
             this.clearAndInitPostList('watcher')
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
     mounted() {
234
     mounted() {

Laden…
Annuleren
Opslaan