From 8a030f519446be06fe4de03d53a9324c54eea59f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Mar 2019 19:31:19 -0700 Subject: [PATCH 1/5] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 7917335c..0610f2d5 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -209,8 +209,8 @@ class PublicApiController extends Controller $this->validate($request,[ 'page' => 'nullable|integer|max:40', - 'min_id' => 'nullable|integer', - 'max_id' => 'nullable|integer', + 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, + 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, 'limit' => 'nullable|integer|max:20' ]); @@ -252,10 +252,10 @@ class PublicApiController extends Controller 'local', 'created_at', 'updated_at' - )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) + )->where('id', $dir, $id) + ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) ->whereLocal(true) ->whereNull('uri') - ->where('id', $dir, $id) ->whereNotIn('profile_id', $filtered) ->whereNull('in_reply_to_id') ->whereNull('reblog_of_id') @@ -303,8 +303,8 @@ class PublicApiController extends Controller $this->validate($request,[ 'page' => 'nullable|integer|max:40', - 'min_id' => 'nullable|integer', - 'max_id' => 'nullable|integer', + 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, + 'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, 'limit' => 'nullable|integer|max:20' ]); From 23459b9afd7b6a57d4df6ce6547ccbf019c7aa91 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Mar 2019 19:32:31 -0700 Subject: [PATCH 2/5] Update Timeline.vue --- resources/assets/js/components/Timeline.vue | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 4d698771..7ff87aad 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -437,17 +437,20 @@ }, fetchTimelineApi() { - let homeTimeline = '/api/v1/timelines/home?page=1'; - let localTimeline = '/api/v1/timelines/public?page=1'; + let homeTimeline = '/api/v1/timelines/home'; + let localTimeline = '/api/v1/timelines/public'; let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline; - axios.get(apiUrl).then(res => { + axios.get(apiUrl, { + params: { + max_id: 0, + limit: 4 + } + }).then(res => { let data = res.data; this.feed.push(...data); let ids = data.map(status => status.id); - this.min_id = Math.min(...ids); - if(this.page == 1) { - this.max_id = Math.max(...ids); - } + this.min_id = Math.max(...ids); + this.max_id = Math.min(...ids); $('.timeline .pagination').removeClass('d-none'); this.loading = false; this.fetchNotifications(); @@ -461,17 +464,16 @@ let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline; axios.get(apiUrl, { params: { - page: this.page, + max_id: this.max_id, + limit: 4 }, }).then(res => { if (res.data.length && this.loading == false) { let data = res.data; this.feed.push(...data); let ids = data.map(status => status.id); - this.min_id = Math.min(...ids); - if(this.page == 1) { - this.max_id = Math.max(...ids); - } + this.min_id = Math.max(...ids); + this.max_id = Math.min(...ids); this.page += 1; $state.loaded(); this.loading = false; From ed2d9d070a57d13ffef540d9f66002bcc740e22b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Mar 2019 19:34:18 -0700 Subject: [PATCH 3/5] Update Discover.vue --- resources/assets/js/components/DiscoverComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/js/components/DiscoverComponent.vue b/resources/assets/js/components/DiscoverComponent.vue index 18049e61..dd3e8786 100644 --- a/resources/assets/js/components/DiscoverComponent.vue +++ b/resources/assets/js/components/DiscoverComponent.vue @@ -1,7 +1,7 @@