From 58e8ac4d44f5aaccc3b15afaa605a0193e6d4e62 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 23 Sep 2019 22:35:31 -0600 Subject: [PATCH] Update Timeline component --- resources/assets/js/components/Timeline.vue | 83 ++++++--------------- 1 file changed, 22 insertions(+), 61 deletions(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 2e90770e9..a6904c652 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -517,13 +517,6 @@ beforeMount() { this.fetchProfile(); this.fetchTimelineApi(); - - // if(this.config.announcement.enabled == true) { - // let msg = $('
') - // .addClass('alert alert-warning mb-0 rounded-0 text-center font-weight-bold') - // .html(this.config.announcement.message); - // $('body').prepend(msg); - // } }, mounted() { @@ -602,7 +595,7 @@ axios.get(apiUrl, { params: { max_id: this.max_id, - limit: 6 + limit: 4 } }).then(res => { let data = res.data; @@ -611,15 +604,20 @@ this.ids = ids; this.min_id = Math.max(...ids); this.max_id = Math.min(...ids); - $('.timeline .pagination').removeClass('d-none'); this.loading = false; - if(this.feed.length == 6) { - this.fetchHashtagPosts(); + $('.timeline .pagination').removeClass('d-none'); + if(this.feed.length == 4) { this.fetchTimelineApi(); - } else { + } + if(this.hashtagPosts.length == 0) { this.fetchHashtagPosts(); } }).catch(err => { + swal( + 'Oops, something went wrong', + 'Please reload the page.', + 'error' + ); }); }, @@ -645,7 +643,7 @@ axios.get(apiUrl, { params: { max_id: this.max_id, - limit: 9 + limit: 6 }, }).then(res => { if (res.data.length && this.loading == false) { @@ -671,32 +669,6 @@ }); }, - loadMore(event) { - let homeTimeline = '/api/pixelfed/v1/timelines/home'; - let localTimeline = '/api/pixelfed/v1/timelines/public'; - let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline; - event.target.innerText = 'Loading...'; - axios.get(apiUrl, { - params: { - page: this.page, - }, - }).then(res => { - if (res.data.length && this.loading == false) { - let data = res.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.feed.push(...data); - this.page += 1; - this.loading = false; - event.target.innerText = 'Load more posts'; - } else { - } - }); - }, - reportUrl(status) { let type = status.in_reply_to ? 'comment' : 'post'; let id = status.id; @@ -752,27 +724,11 @@ return ts.toDateString() + ' ' + ts.toLocaleTimeString(); }, - editUrl(status) { - return status.url + '/edit'; - }, - redirect(url) { window.location.href = url; return; }, - replyUrl(status) { - let username = this.profile.username; - let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id; - return '/p/' + username + '/' + id; - }, - - mentionUrl(status) { - let username = status.account.username; - let id = status.id; - return '/p/' + username + '/' + id; - }, - statusOwner(status) { let sid = status.account.id; let uid = this.profile.id; @@ -1089,6 +1045,8 @@ }, expRec() { + return; + if(this.config.ab.rec == false) { return; } @@ -1099,6 +1057,8 @@ }, expRecFollow(id, index) { + return; + if(this.config.ab.rec == false) { return; } @@ -1170,6 +1130,8 @@ }, refreshSuggestions() { + return; + let el = event.target.parentNode; if(el.classList.contains('disabled') == true) { return; @@ -1226,10 +1188,10 @@ ctxMenu(status) { this.ctxMenuStatus = status; - let payload = '