Переглянути джерело

:recycle: removed type watch init

tags/0.9.0
J 4 роки тому
джерело
коміт
a71bce3d96
1 змінених файлів з 13 додано та 10 видалено
  1. 13
    10
      vue-theme/src/pages/list.vue

+ 13
- 10
vue-theme/src/pages/list.vue Переглянути файл

151
         },
151
         },
152
         setIntersectionLoader() {
152
         setIntersectionLoader() {
153
             // KeepFetching is UNSET for certain post types and sort types in `loadMorePosts()`
153
             // KeepFetching is UNSET for certain post types and sort types in `loadMorePosts()`
154
-            if(!this.keepFetching) return console.warn('cannot setup intersection handler keepFetching is set false')
154
+            if(!this.keepFetching) return console.warn('Cannot setup intersection handler keepFetching is set false')
155
             
155
             
156
             // Always unset before setting the intersection loader
156
             // Always unset before setting the intersection loader
157
             this.unsetIntersectionLoader()
157
             this.unsetIntersectionLoader()
199
         // and the post type has changed
199
         // and the post type has changed
200
         type(newType, oldType) {
200
         type(newType, oldType) {
201
             if(!postTypes.includes(newType)) return console.warn('type not valid...')
201
             if(!postTypes.includes(newType)) return console.warn('type not valid...')
202
-
203
-            // Ignore event or exhibition because they're sortable
204
-            // They're often loaded from sidebar
205
-            const ignored = ['event', 'exhibition']
206
-            if(ignored.includes(this.type)) return
207
-            
208
-            this.clearAndInitPostList('type watcher')
209
         },
202
         },
210
         // Only fire if the sort type has changed
203
         // Only fire if the sort type has changed
211
         // and the post type is the same
204
         // and the post type is the same
212
         // and both sorts are valid
205
         // and both sorts are valid
213
         $route(to, from) {
206
         $route(to, from) {
214
             const validSorts = Object.values(sortTypes)
207
             const validSorts = Object.values(sortTypes)
208
+
209
+            // Ignore event or exhibition because they're sortable
210
+            // They're often loaded from sidebar
211
+            const ignoredFromTypeChange = ['event', 'exhibition']
215
             if (
212
             if (
213
+                typeFromRoute(to) != typeFromRoute(from) &&
214
+                !ignoredFromTypeChange.includes(typeFromRoute(to))
215
+            ) {
216
+                this.clearAndInitPostList('type change')
217
+            }
218
+            else if (
216
                 typeFromRoute(to) == typeFromRoute(from) &&
219
                 typeFromRoute(to) == typeFromRoute(from) &&
217
                 // Post slug sometimes appears as a sort so we check it against known sorts
220
                 // Post slug sometimes appears as a sort so we check it against known sorts
218
                 validSorts.includes(to.sortBy) && validSorts.includes(from.sortBy)
221
                 validSorts.includes(to.sortBy) && validSorts.includes(from.sortBy)
219
             ) {
222
             ) {
220
-                console.log('$route watcher fired', to, from)
223
+                console.log('$route watcher:sort changed fired', to, from)
221
             } 
224
             } 
222
         }
225
         }
223
     },
226
     },
224
     mounted() {
227
     mounted() {
225
-        // This only fires navigating from a single page, to a list page
228
+        // This only fires navigating from a non-list page > list page
226
         this.clearAndInitPostList('mounted')
229
         this.clearAndInitPostList('mounted')
227
     },
230
     },
228
     beforeDestroy() {
231
     beforeDestroy() {

Завантаження…
Відмінити
Зберегти