From 56215be73a02437971b5f765833ebf04df079856 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 1 Jun 2021 23:40:34 -0600 Subject: [PATCH] Update Timeline, add recent home feed --- resources/assets/js/components/Timeline.vue | 355 ++++++++++++++++++-- 1 file changed, 334 insertions(+), 21 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index ec7a158a6..543f54320 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -34,7 +34,8 @@ Loading... -
+ +
@@ -118,7 +119,7 @@
-
+
+
-
-
+
+
-
No more posts to load
-
No more posts to load
+
+
+

+

You're All Caught Up!

+

You've seen all the new posts from the accounts you follow.

+

+ View Older Posts +

+
+
+

You've reached the end of this feed

+

+ Discover new posts and people +

+
+
+
+
+

+

You're All Caught Up!

+

You've seen all the new posts from the accounts you follow.

+

+ View Older Posts +

+
+
+

You've reached the end of this feed

+

+ Discover new posts and people +

+
+
-
-
-

Hello, {{profile.acct}}

-

-

Start following people to build your timeline.

-

Discover new people and posts

+
+
+

+

You're All Caught Up!

+

You've seen all the new posts from the accounts you follow.

+

+ View Older Posts +

+
+
+

+

Hello {{profile.username}}

+

Accounts you follow will appear in this feed.

+

+ Discover new posts and people +

+ +
+

+ Suggested Posts + Older Posts +

+
+ +
+ +
+
+
Suggestions For You
+ +
+
+
+
+
+

+ + avatar + +

+
+

+ + {{rec.username}} + +

+

{{rec.message}}

+
+

+ Follow +

+
+
+
+
+
+ + + +
+
+ + +
+ avatar +
+ +
+ +
+
+ +
+ +
+
+
+

+
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+

Error: Problem rendering preview.

+
+ +
+ +
+

+ + + For information about COVID-19, {{config.features.label.covid.org}} + + + + +

+
+ +
+ + +
+

+ + + + · + Based on popular and trending content +

+
+
+ + + + +
+
+
@@ -916,7 +1190,10 @@ }, discover_min_id: 0, discover_max_id: 0, - discover_feed: [] + discover_feed: [], + recentFeed: this.scope === 'home' ? true : false, + recentFeedMin: null, + recentFeedMax: null } }, @@ -946,6 +1223,19 @@ }, beforeMount() { + let u = new URLSearchParams(window.location.search); + if(u.has('a')) { + switch(u.get('a')) { + case 'recent_feed': + if(this.scope === 'home') { + this.recentFeed = true; + } + break; + case 'vop': + this.recentFeed = false; + break; + } + } this.fetchProfile(); this.fetchTimelineApi(); }, @@ -979,8 +1269,12 @@ this.$nextTick(function () { $('[data-toggle="tooltip"]').tooltip(); let u = new URLSearchParams(window.location.search); - if(u.has('a') && u.get('a') == 'co') { - $('#composeModal').modal('show'); + if(u.has('a')) { + switch(u.get('a')) { + case 'co': + $('#composeModal').modal('show'); + break; + } } }); }, @@ -1029,7 +1323,8 @@ axios.get(apiUrl, { params: { max_id: this.max_id, - limit: 3 + limit: 3, + recent_feed: this.recentFeed } }).then(res => { let data = res.data; @@ -1040,9 +1335,7 @@ this.max_id = Math.min(...ids).toString(); this.loading = false; $('.timeline .pagination').removeClass('d-none'); - // if(this.feed.length == 4) { - // this.fetchTimelineApi(); - // } + if(this.hashtagPosts.length == 0) { this.fetchHashtagPosts(); } @@ -1053,6 +1346,16 @@ i.href = App.util.format.rewriteLinks(i); }); }, 500); + + axios.get('/api/pixelfed/v2/discover/posts/trending', { + params: { + range: 'daily' + } + }).then(res => { + let data = res.data.filter(post => this.ids.indexOf(post.id) === -1); + this.discover_feed = data; + }); + }).catch(err => { swal( 'Oops, something went wrong', @@ -1071,7 +1374,9 @@ this.loading = false; $state.complete(); } + let apiUrl = false; + switch(this.scope) { case 'home': apiUrl = '/api/pixelfed/v1/timelines/home'; @@ -1085,16 +1390,23 @@ apiUrl = '/api/pixelfed/v1/timelines/network'; break; } + axios.get(apiUrl, { params: { max_id: this.max_id, - limit: 6 + limit: 6, + recent_feed: this.recentFeed }, }).then(res => { if (res.data.length && this.loading == false) { let data = res.data; let self = this; let vids = []; + if(self.recentFeed && self.ids.indexOf(data[0].id) != -1) { + this.loading = false; + $state.complete(); + return; + } data.forEach((d, index) => { if(self.ids.indexOf(d.id) == -1) { self.feed.push(d); @@ -1936,7 +2248,8 @@ axios.get(apiUrl, { params: { max_id: 0, - limit: 20 + limit: 20, + recent_feed: this.recentFeed } }).then(res => { let self = this;