From a1059a6e12103815e64b59e513fe9ee01980ba5a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 5 Feb 2021 21:20:19 -0700 Subject: [PATCH] Update DiscoverComponent, allow unathenicated if enabled --- .../js/components/DiscoverComponent.vue | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/resources/assets/js/components/DiscoverComponent.vue b/resources/assets/js/components/DiscoverComponent.vue index e1fa217a4..b16bf3375 100644 --- a/resources/assets/js/components/DiscoverComponent.vue +++ b/resources/assets/js/components/DiscoverComponent.vue @@ -4,7 +4,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
@@ -151,6 +151,7 @@ export default { data() { return { + authenticated: false, loaded: false, config: window.App.config, posts: {}, @@ -163,14 +164,21 @@ recommendedLoading: true } }, + + beforeMount() { + this.authenticated = $('body').hasClass('loggedIn'); + }, + mounted() { this.loaded = true; this.loadTrending(); - this.fetchData(); - axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { - window._sharedData.curUser = res.data; - window.App.util.navatar(); - }); + if($('body').hasClass('loggedIn') == true) { + this.fetchData(); + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { + window._sharedData.curUser = res.data; + window.App.util.navatar(); + }); + } }, methods: { @@ -180,7 +188,7 @@ } axios.get('/api/pixelfed/v2/discover/posts') .then((res) => { - this.posts = res.data.posts; + this.posts = res.data.posts.filter(r => r != null); this.recommendedLoading = false; }); }, @@ -206,13 +214,16 @@ } }) .then(res => { + let data = res.data.filter(r => { + return r !== null; + }); if(this.trendingRange == 'daily') { - this.trendingDaily = res.data.filter(t => t.sensitive == false); + this.trendingDaily = data.filter(t => t.sensitive == false); } if(this.trendingRange == 'monthly') { - this.trendingMonthly = res.data.filter(t => t.sensitive == false); + this.trendingMonthly = data.filter(t => t.sensitive == false); } - this.trending = res.data; + this.trending = data; this.trendingLoading = false; }); },