Procházet zdrojové kódy

:recycle: adding back sidebar | removing logs | cleaning up

tags/0.9.0
J před 4 roky
rodič
revize
4625728a6a
1 změnil soubory, kde provedl 13 přidání a 13 odebrání
  1. 13
    13
      vue-theme/src/pages/list.vue

+ 13
- 13
vue-theme/src/pages/list.vue Zobrazit soubor

23
             p {{ `${type} count: ${Object.values(posts).length}` }}
23
             p {{ `${type} count: ${Object.values(posts).length}` }}
24
             p {{ `show sidebar: ${sidebar}` }}
24
             p {{ `show sidebar: ${sidebar}` }}
25
 
25
 
26
-    //- sidebar(v-if="sidebar" :type="`${type}`" layout="list")
26
+    sidebar(v-if="sidebar" :type="`${type}`" layout="list")
27
 </template>
27
 </template>
28
 
28
 
29
 <script>
29
 <script>
35
 import { postTypes, convertTitleCase, typeFromRoute } from '@/utils/helpers'
35
 import { postTypes, convertTitleCase, typeFromRoute } from '@/utils/helpers'
36
 
36
 
37
 const TIMEOUT = 1
37
 const TIMEOUT = 1
38
-const INTERSECT_SELECTION = ".page--list > article footer"
38
+const INTERSECT_SELECTOR = ".page--list > article footer"
39
 export default {
39
 export default {
40
     components: { sidebar, featuredImage, card },
40
     components: { sidebar, featuredImage, card },
41
     props: {
41
     props: {
47
     data() {
47
     data() {
48
         return {
48
         return {
49
             page: 0,
49
             page: 0,
50
-            perPage: 15,
50
+            perPage: 21,
51
             keepFetching: true,
51
             keepFetching: true,
52
             loadingFetched: false,
52
             loadingFetched: false,
53
             observer: null
53
             observer: null
85
 
85
 
86
             console.warn(`loading more ${type} posts...`)
86
             console.warn(`loading more ${type} posts...`)
87
             this.loadingFetched = true
87
             this.loadingFetched = true
88
+            console.warn(
89
+                `loading page ${this.page + 1} of ${type} posts: 
90
+                    ${this.page * this.perPage + 1} through 
91
+                    ${(this.page + 1) * this.perPage}`
92
+            )
88
             this.page++
93
             this.page++
89
             await this.getPosts()
94
             await this.getPosts()
90
         },
95
         },
108
         async getPosts() {
113
         async getPosts() {
109
             // Edge case for episodes
114
             // Edge case for episodes
110
             await this._getAll('episode', this.$store)
115
             await this._getAll('episode', this.$store)
111
-
116
+            
112
             const dispatchAction = `getMore${this.pType}`
117
             const dispatchAction = `getMore${this.pType}`
113
             let res = null
118
             let res = null
114
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
119
             if(this.pType && dispatchAction != `getMoreEpisodes`) {
120
 
125
 
121
             // Stop trying to load more posts
126
             // Stop trying to load more posts
122
             if(res && !res.length) {
127
             if(res && !res.length) {
123
-                console.warn('nothing left to get...')
128
+                console.warn(`empty response for ${this.type}:`, res)
124
                 this.keepFetching = false
129
                 this.keepFetching = false
125
             }
130
             }
126
             this.loadingFetched = false
131
             this.loadingFetched = false
135
             // We always set a hero no matter what
140
             // We always set a hero no matter what
136
             // Because the hero component will deal
141
             // Because the hero component will deal
137
             // with how to render based on hero.url
142
             // with how to render based on hero.url
138
-            if(!this.allPages) return console.log('no pages in state', this)
143
+            if(!this.allPages) return console.warn('no pages in state', this)
139
             const page = this.allPages.filter(
144
             const page = this.allPages.filter(
140
                 page => page.slug == type + 's',
145
                 page => page.slug == type + 's',
141
             )[0]
146
             )[0]
146
         setIntersectionLoader() {
151
         setIntersectionLoader() {
147
             if(!this.type) return console.error('cannot setup interseciton handler for undefined type')
152
             if(!this.type) return console.error('cannot setup interseciton handler for undefined type')
148
 
153
 
149
-            console.warn('setting up intersection handler for:', this.type)
150
-            const footerEl = document.querySelector(INTERSECT_SELECTION)
151
-            // console.warn('found el: ',footerEl)
154
+            const footerEl = document.querySelector(INTERSECT_SELECTOR)
152
             if(!footerEl) return
155
             if(!footerEl) return
153
-            // console.warn('attach to: ',footerEl)
154
 
156
 
155
             const onIntersect = (entries, observer) => {
157
             const onIntersect = (entries, observer) => {
156
-                console.log('intersection handler fired...')
157
                 entries.forEach(entry => {
158
                 entries.forEach(entry => {
158
                     if (!entry.isIntersecting || this.loadingFetched) return
159
                     if (!entry.isIntersecting || this.loadingFetched) return
159
-                    console.log("intersected:", entry)
160
                     setTimeout(() => {
160
                     setTimeout(() => {
161
                         this.loadMorePosts()
161
                         this.loadMorePosts()
162
                     }, TIMEOUT)
162
                     }, TIMEOUT)
169
             this.observer.observe(footerEl)
169
             this.observer.observe(footerEl)
170
         },
170
         },
171
         unsetIntersectionLoader() {
171
         unsetIntersectionLoader() {
172
-            const footerEl = document.querySelector(INTERSECT_SELECTION)
172
+            const footerEl = document.querySelector(INTERSECT_SELECTOR)
173
             if(!footerEl) return
173
             if(!footerEl) return
174
 
174
 
175
             console.warn('unsetting intersection handler on:', footerEl)
175
             console.warn('unsetting intersection handler on:', footerEl)

Načítá se…
Zrušit
Uložit