Browse Source

Update Timeline.vue, improve CHT pagination

Daniel Supernault 1 year ago
parent
commit
9c43e7e265
1 changed files with 23 additions and 6 deletions
  1. 23 6
      resources/assets/components/sections/Timeline.vue

+ 23 - 6
resources/assets/components/sections/Timeline.vue

@@ -186,7 +186,8 @@
                 sharesModalPost: {},
                 forceUpdateIdx: 0,
                 showReblogBanner: false,
-                enablingReblogs: false
+                enablingReblogs: false,
+                baseApi: '/api/v1/pixelfed/timelines/',
             }
         },
 
@@ -201,6 +202,10 @@
                     return;
                 };
             }
+            if(window.App.config.ab.hasOwnProperty('cached_home_timeline')) {
+                const cht = window.App.config.ab.cached_home_timeline == true;
+                this.baseApi = cht ? '/api/v1/timelines/' : '/api/pixelfed/v1/timelines/';
+            }
             this.fetchSettings();
         },
 
@@ -247,7 +252,7 @@
             fetchTimeline(scrollToTop = false) {
                 let url, params;
                 if(this.getScope() === 'home' && this.settings && this.settings.hasOwnProperty('enable_reblogs') && this.settings.enable_reblogs) {
-                    url = `/api/v1/timelines/home`;
+                    url = this.baseApi + `home`;
                     params = {
                         '_pe': 1,
                         max_id: this.max_id,
@@ -255,12 +260,17 @@
                         include_reblogs: true,
                     }
                 } else {
-                    url = `/api/pixelfed/v1/timelines/${this.getScope()}`;
+                    url = this.baseApi + this.getScope();
                     params = {
                         max_id: this.max_id,
                         limit: 6,
+                        '_pe': 1,
                     }
                 }
+                if(this.getScope() === 'network') {
+                    params.remote = true;
+                    url = this.baseApi + `public`;
+                }
                 axios.get(url, {
                     params: params
                 }).then(res => {
@@ -278,7 +288,7 @@
                     this.max_id = Math.min(...ids);
                     this.feed = res.data;
 
-                    if(res.data.length !== 6) {
+                    if(res.data.length < 4) {
                         this.canLoadMore = false;
                         this.showLoadMore = true;
                     }
@@ -306,7 +316,8 @@
 
                 let url, params;
                 if(this.getScope() === 'home' && this.settings && this.settings.hasOwnProperty('enable_reblogs') && this.settings.enable_reblogs) {
-                    url = `/api/v1/timelines/home`;
+                    url = this.baseApi + `home`;
+
                     params = {
                         '_pe': 1,
                         max_id: this.max_id,
@@ -314,12 +325,18 @@
                         include_reblogs: true,
                     }
                 } else {
-                    url = `/api/pixelfed/v1/timelines/${this.getScope()}`;
+                    url = this.baseApi + this.getScope();
                     params = {
                         max_id: this.max_id,
                         limit: 6,
+                        '_pe': 1,
                     }
                 }
+                if(this.getScope() === 'network') {
+                    params.remote = true;
+                    url = this.baseApi + `public`;
+
+                }
                 axios.get(url, {
                     params: params
                 }).then(res => {