Parcourir la source

:recycle: adding back try catch

tags/0.9.0
J il y a 4 ans
Parent
révision
228ba30b69
1 fichiers modifiés avec 13 ajouts et 12 suppressions
  1. 13
    12
      vue-theme/src/pages/list.vue

+ 13
- 12
vue-theme/src/pages/list.vue Voir le fichier

165
             console.warn('Setting interesection loader...')
165
             console.warn('Setting interesection loader...')
166
             
166
             
167
             // Always unset and reset the intersection loader
167
             // Always unset and reset the intersection loader
168
-            const footerEl = this.unsetIntersectionLoader()
168
+            this.unsetIntersectionLoader()
169
 
169
 
170
             const onIntersect = (entries, observer) => {
170
             const onIntersect = (entries, observer) => {
171
                 entries.forEach(entry => {
171
                 entries.forEach(entry => {
173
                     setTimeout(() => this.loadMorePosts(), TIMEOUT)
173
                     setTimeout(() => this.loadMorePosts(), TIMEOUT)
174
                 })
174
                 })
175
             }
175
             }
176
-            this.observer = new IntersectionObserver(onIntersect, {
177
-                threshold: 0.80
178
-            })
179
-            this.observer['_for_type'] = this.type
180
-            this.observer.observe(footerEl)
176
+            this.observer = new IntersectionObserver(onIntersect, { threshold: 0.80 })
177
+            this.observer.observe(document.querySelector(INTERSECT_SELECTOR))
181
             console.log('--- observer')
178
             console.log('--- observer')
182
             console.log(this.observer)
179
             console.log(this.observer)
183
         },
180
         },
184
         unsetIntersectionLoader() {
181
         unsetIntersectionLoader() {
185
             const footerEl = document.querySelector(INTERSECT_SELECTOR)
182
             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()
191
-            return footerEl
183
+            try {
184
+                if(!footerEl) throw `cannot unset intersection handler missing el: ${footerEl}`
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)
189
+                this.observer.disconnect()
190
+            } catch (error) {
191
+                console.error(error)
192
+            }
192
         },
193
         },
193
         clearAndInitPostList(caller) {
194
         clearAndInitPostList(caller) {
194
             console.log(`clearAndInitPostList from ${caller}...`)
195
             console.log(`clearAndInitPostList from ${caller}...`)

Chargement…
Annuler
Enregistrer