소스 검색

:recycle: rearranging get page | ignoring pages in getPosts

tags/0.9.0
J 4 년 전
부모
커밋
a5886fcfae
1개의 변경된 파일19개의 추가작업 그리고 28개의 파일을 삭제
  1. 19
    28
      vue-theme/src/pages/list.vue

+ 19
- 28
vue-theme/src/pages/list.vue 파일 보기

116
             let dispatchAction = `getMore${this.pType}`
116
             let dispatchAction = `getMore${this.pType}`
117
             let params = this._getDispatchParams()
117
             let params = this._getDispatchParams()
118
             
118
             
119
-            // For episodes or material sort we grab EVERYTHING
119
+            // For episodes, or material sort we grab EVERYTHING
120
             if(this.type == 'episode' || this.type == 'artist' && this._getSortBy() == sortTypes.material) {
120
             if(this.type == 'episode' || this.type == 'artist' && this._getSortBy() == sortTypes.material) {
121
                 dispatchAction = `getAll${this.pType}`
121
                 dispatchAction = `getAll${this.pType}`
122
                 params = this._getDispatchParams(-1)
122
                 params = this._getDispatchParams(-1)
123
+                
124
+                // Clear sortType if this is an episodes list
125
+                params.sortType = this.type == 'episode' ? null : params.sortType
123
             }
126
             }
124
 
127
 
125
-            const ignore = ['getMorePages']
126
             let res = null
128
             let res = null
127
-            if(this.pType && !ignore.includes(dispatchAction) && this.keepFetching) {
129
+            // We always grab all pages on hero init so no need to do it here
130
+            if(this.pType && this.keepFetching && this.type != 'page') {
128
                 res = await this.$store.dispatch(dispatchAction, params)
131
                 res = await this.$store.dispatch(dispatchAction, params)
129
             }
132
             }
130
 
133
 
135
             }
138
             }
136
             this.loadingFetched = false
139
             this.loadingFetched = false
137
         },
140
         },
141
+        async getPageForType(type) {
142
+            await this._getAll('page', this.$store)
143
+            if(!this.allPages) return console.warn('no pages in state', this)
144
+            const page = this.allPages.filter(page => page.slug == `${type}s`)[0]
145
+            if(!page) return console.warn(`no page for ${type} found`)
146
+            return page
147
+        },
138
         // _setHeroInfo(post) {} from mixin
148
         // _setHeroInfo(post) {} from mixin
139
         // _clearHero(store) {} from mixin
149
         // _clearHero(store) {} from mixin
140
         async checkAndSetHero(type) {
150
         async checkAndSetHero(type) {
141
             this._clearHero(this.$store)
151
             this._clearHero(this.$store)
142
-
143
-            await this._getAll('page', this.$store)
144
-
152
+            const page = await this.getPageForType(type)
145
             // We always set a hero no matter what
153
             // We always set a hero no matter what
146
             // Because the hero component will deal
154
             // Because the hero component will deal
147
             // with how to render based on hero.url
155
             // with how to render based on hero.url
148
-            if(!this.allPages) return console.warn('no pages in state', this)
149
-            const page = this.allPages.filter(
150
-                page => page.slug == `${type}s`,
151
-            )[0]
152
-            if(!page) return console.warn(`no page for ${type} found`)
153
-
154
             this.$store.commit('SET_HERO', this._setHeroInfo(page))
156
             this.$store.commit('SET_HERO', this._setHeroInfo(page))
155
         },
157
         },
156
         setIntersectionLoader() {
158
         setIntersectionLoader() {
163
             const onIntersect = (entries, observer) => {
165
             const onIntersect = (entries, observer) => {
164
                 entries.forEach(entry => {
166
                 entries.forEach(entry => {
165
                     if (!entry.isIntersecting || this.loadingFetched) return
167
                     if (!entry.isIntersecting || this.loadingFetched) return
166
-                    setTimeout(() => {
167
-                        this.loadMorePosts()
168
-                    }, TIMEOUT)
168
+                    setTimeout(() => this.loadMorePosts(), TIMEOUT)
169
                 })
169
                 })
170
             }
170
             }
171
             this.observer = new IntersectionObserver(onIntersect, {
171
             this.observer = new IntersectionObserver(onIntersect, {
173
             })
173
             })
174
             this.observer['_for_type'] = this.type
174
             this.observer['_for_type'] = this.type
175
             this.observer.observe(footerEl)
175
             this.observer.observe(footerEl)
176
+            console.log('--- observer')
177
+            console.log(this.observer)
176
         },
178
         },
177
         unsetIntersectionLoader() {
179
         unsetIntersectionLoader() {
178
             const footerEl = document.querySelector(INTERSECT_SELECTOR)
180
             const footerEl = document.querySelector(INTERSECT_SELECTOR)
220
                 this.setIntersectionLoader()
222
                 this.setIntersectionLoader()
221
             }
223
             }
222
 
224
 
223
-            // Check if we changed sort method
224
-            // from no sort to sorted
225
-            // or sorted to no sort
226
-            // or sort to a different sort(?)
227
-            if(
228
-                from.fullPath.includes(this.sortBy) ||
229
-                (!to.fullPath.includes(this.sortBy) && !from.fullPath.includes(this.sortBy))
230
-            ) {
231
-                const ignore = ['event', 'exhibition', 'post']
232
-                if(ignore.includes(this.type)) return
233
-                console.log('init from $route watch...')
234
-                this.clearAndInitPostList()
235
-            }
225
+            console.log('init from $route watch...')
226
+            this.clearAndInitPostList()
236
         }
227
         }
237
     },
228
     },
238
     mounted() {
229
     mounted() {

Loading…
취소
저장