Преглед изворни кода

:recycle: clearing and init on type watch

tags/0.9.0
J пре 4 година
родитељ
комит
0ece6ba79b
1 измењених фајлова са 7 додато и 14 уклоњено
  1. 7
    14
      vue-theme/src/pages/list.vue

+ 7
- 14
vue-theme/src/pages/list.vue Прегледај датотеку

103
             }
103
             }
104
         },
104
         },
105
         async getPosts() {
105
         async getPosts() {
106
+            // Edge case for episodes
107
+            await this._getAll('episode', this.$store)
108
+
106
             const dispatchAction = `getMore${this.pType}`
109
             const dispatchAction = `getMore${this.pType}`
107
-            // pType sometimes is undefined so need to dispatch and
108
             let res = null
110
             let res = null
109
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
111
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
110
                 res = await this.$store.dispatch(
112
                 res = await this.$store.dispatch(
113
                 )
115
                 )
114
             }
116
             }
115
 
117
 
116
-            // Edge case for episodes
117
-            await this._getAll('episode', this.$store)
118
-
119
             // Stop trying to load more posts
118
             // Stop trying to load more posts
120
             if(res && !res.length) {
119
             if(res && !res.length) {
121
                 console.warn('nothing left to get...')
120
                 console.warn('nothing left to get...')
147
 
146
 
148
             window.addEventListener("load", e => {
147
             window.addEventListener("load", e => {
149
                 const observer = new IntersectionObserver(this.loadMorePosts, {
148
                 const observer = new IntersectionObserver(this.loadMorePosts, {
150
-                    rootMargin: "0px 0px 20px 0px",
149
+                    rootMargin: "0px 0px -50px 0px",
151
                 })
150
                 })
152
                 observer.observe(footerEl)
151
                 observer.observe(footerEl)
153
             }, false)
152
             }, false)
168
         }
167
         }
169
     },
168
     },
170
     watch: {
169
     watch: {
170
+        // This only fires navigating from
171
+        // a list page, to another list page
171
         type(newType, oldType){
172
         type(newType, oldType){
172
             console.log('old:', oldType)
173
             console.log('old:', oldType)
173
             console.log('new:', newType)
174
             console.log('new:', newType)
174
-        },
175
-        // This only fires navigating from
176
-        // a list page, to another list page
177
-        $route(to, from) {
178
-            // Always reset the page count & fetch flag
179
-            console.log('route to:', to)
180
-            console.log('route from:', from)
181
-            if(to.fullPath.split('/').length < 1) return
182
-            // this.clearAndInitPostList()
175
+            this.clearAndInitPostList()
183
         },
176
         },
184
     },
177
     },
185
     mounted() {
178
     mounted() {

Loading…
Откажи
Сачувај