瀏覽代碼

:recycle: remove try catch for intersection

tags/0.9.0
J 4 年之前
父節點
當前提交
c155f86ebb
共有 1 個檔案被更改,包括 11 行新增14 行删除
  1. 11
    14
      vue-theme/src/pages/list.vue

+ 11
- 14
vue-theme/src/pages/list.vue 查看文件

182
             console.log(this.observer)
182
             console.log(this.observer)
183
         },
183
         },
184
         unsetIntersectionLoader() {
184
         unsetIntersectionLoader() {
185
-            try {
186
-                const footerEl = document.querySelector(INTERSECT_SELECTOR)
187
-                console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
188
-                this.observer.unobserve(footerEl)
189
-                this.observer.disconnect()
190
-            } catch (err) {
191
-                console.error(`cannot unset intersection handler. Have you tried setting the el: ${footerEl} or observer: ${this.observer} ?\n`)
192
-                console.error(`More info: ${err}`)
193
-            }
185
+            const footerEl = document.querySelector(INTERSECT_SELECTOR)
186
+            if(!footerEl || !this.observer) return console.error(`cannot unset intersection handler missing el: ${footerEl} or observer: ${this.observer}`)
187
+            
188
+            console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
189
+            this.observer.unobserve(footerEl)
190
+            this.observer.disconnect()
194
             return footerEl
191
             return footerEl
195
         },
192
         },
196
-        clearAndInitPostList() {
193
+        clearAndInitPostList(caller) {
194
+            console.log(`clearAndInitPostList from ${caller}...`)
197
             console.log('---')
195
             console.log('---')
196
+
198
             this.page = 0
197
             this.page = 0
199
             this.keepFetching = true
198
             this.keepFetching = true
200
 
199
 
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
-            console.log('init from type watch...')
218
-            this.clearAndInitPostList()
216
+            this.clearAndInitPostList('watcher')
219
         }
217
         }
220
     },
218
     },
221
     mounted() {
219
     mounted() {
222
         // This only fires navigating from a single page, to a list page
220
         // This only fires navigating from a single page, to a list page
223
-        console.log('init from mounted...')
224
-        this.clearAndInitPostList()
221
+        this.clearAndInitPostList('mounted')
225
     },
222
     },
226
     beforeDestroy() {
223
     beforeDestroy() {
227
         this.unsetIntersectionLoader()
224
         this.unsetIntersectionLoader()

Loading…
取消
儲存