From 9c43e7e26505700f98cd094d7b0b6cd00205b531 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 8 Dec 2023 05:25:03 -0700 Subject: [PATCH] Update Timeline.vue, improve CHT pagination --- .../assets/components/sections/Timeline.vue | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/resources/assets/components/sections/Timeline.vue b/resources/assets/components/sections/Timeline.vue index dd2c7d2f0..6b064acea 100644 --- a/resources/assets/components/sections/Timeline.vue +++ b/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 => {