Ver código fonte

:recycle: removed type watch init

tags/0.9.0
J 4 anos atrás
pai
commit
a71bce3d96
1 arquivos alterados com 13 adições e 10 exclusões
  1. 13
    10
      vue-theme/src/pages/list.vue

+ 13
- 10
vue-theme/src/pages/list.vue Ver arquivo

@@ -151,7 +151,7 @@ export default {
151 151
         },
152 152
         setIntersectionLoader() {
153 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 156
             // Always unset before setting the intersection loader
157 157
             this.unsetIntersectionLoader()
@@ -199,30 +199,33 @@ export default {
199 199
         // and the post type has changed
200 200
         type(newType, oldType) {
201 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 203
         // Only fire if the sort type has changed
211 204
         // and the post type is the same
212 205
         // and both sorts are valid
213 206
         $route(to, from) {
214 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 212
             if (
213
+                typeFromRoute(to) != typeFromRoute(from) &&
214
+                !ignoredFromTypeChange.includes(typeFromRoute(to))
215
+            ) {
216
+                this.clearAndInitPostList('type change')
217
+            }
218
+            else if (
216 219
                 typeFromRoute(to) == typeFromRoute(from) &&
217 220
                 // Post slug sometimes appears as a sort so we check it against known sorts
218 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 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 229
         this.clearAndInitPostList('mounted')
227 230
     },
228 231
     beforeDestroy() {

Carregando…
Cancelar
Salvar