From c238b82ed15820d7be2dc14696f42fa0098e5d04 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 11 Aug 2020 19:11:12 -0600 Subject: [PATCH] Update vue components --- .../assets/js/components/PostComponent.vue | 16 ++- .../assets/js/components/SearchResults.vue | 108 +++++++++++++++++- resources/assets/js/components/Timeline.vue | 15 ++- 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 8b0c0e115..e3c4253fb 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -859,7 +859,9 @@ export default { } } this.loaded = true; - this.fetchProfilePosts(); + setTimeout(function() { + self.fetchProfilePosts(); + }, 3000); setTimeout(function() { document.querySelectorAll('.status-comment .comment-text a').forEach(function(i, e) { if(i.href.startsWith(window.location.origin)) { @@ -947,12 +949,16 @@ export default { } else { this.reactions.liked = true; let user = this.user; - this.likes.push(user); + this.likes.unshift(user); + setTimeout(function() { + event.target.classList.add('animate__animated', 'animate__bounce'); + },100); } }).catch(err => { console.error(err); swal('Error', 'Something went wrong, please try again later.', 'error'); }); + window.navigator.vibrate(200); }, shareStatus() { @@ -1383,6 +1389,9 @@ export default { }, fetchProfilePosts() { + if(!$('body').hasClass('loggedIn') && this.loaded) { + return; + } let self = this; let apiUrl = '/api/pixelfed/v1/accounts/' + this.statusProfileId + '/statuses'; axios.get(apiUrl, { @@ -1426,6 +1435,9 @@ export default { }, showTaggedPeopleModal() { + if(!$('body').hasClass('loggedIn') && this.loaded) { + return; + } this.$refs.taggedModal.show(); }, diff --git a/resources/assets/js/components/SearchResults.vue b/resources/assets/js/components/SearchResults.vue index 12d11b2c0..62328c6eb 100644 --- a/resources/assets/js/components/SearchResults.vue +++ b/resources/assets/js/components/SearchResults.vue @@ -11,10 +11,57 @@
-
+

Showing results for {{query}}

+
+ {{formatCount(results.placesPagination.total)}} +
+ + +
+
+
+

+
+
+

PLACES ({{results.placesPagination.total}})

+
+
+ +
+
+
+

+ {{hashtag.value}} +

+
+
+
+
+

+ + Previous + + + Previous + + + {{placesCursor}}/{{results.placesPagination.last_page}} + + + Next + + + Next + +

+
+
+
No results found
+
+

HASHTAGS ({{results.hashtags.length}})

@@ -284,7 +331,8 @@ export default { results: { hashtags: [], profiles: [], - statuses: [] + statuses: [], + places: [], }, filters: { hashtags: true, @@ -292,6 +340,10 @@ export default { statuses: true }, analysis: 'profile', + showPlaces: false, + placesCursor: 1, + placesCache: [], + placesSearchEnabled: false } }, beforeMount() { @@ -300,6 +352,9 @@ export default { mounted() { $('.search-bar input').val(this.query); }, + updated() { + $('[data-toggle="tooltip"]').tooltip(); + }, methods: { bootSearch() { let lexer = this.searchLexer(); @@ -388,7 +443,7 @@ export default { params: { 'q': this.query, 'src': 'metro', - 'v': 1, + 'v': 2, 'scope': 'all' } }).then(res => { @@ -396,6 +451,9 @@ export default { this.results.hashtags = results.hashtags ? results.hashtags : []; this.results.profiles = results.profiles ? results.profiles : []; this.results.statuses = results.posts ? results.posts : []; + this.results.places = results.places ? results.places : []; + this.placesCache = results.places; + this.results.placesPagination = results.placesPagination ? results.placesPagination : []; this.loading = false; }).catch(err => { this.loading = false; @@ -500,6 +558,50 @@ export default { this.networkError = true; break; } + }, + + placesPrevPage() { + this.placesCursor--; + if(this.placesCursor == 1) { + this.results.places = this.placesCache.slice(0, 20); + return; + } + let plc = this.placesCursor * 20; + this.results.places = this.placesCache.slice(plc, 20); + return; + }, + + placesNextPage() { + this.placesCursor++; + let plc = this.placesCursor * 20; + if(this.placesCache.length > 20) { + this.results.places = this.placesCache.slice(this.placesCursor == 1 ? 0 : plc, 20); + return; + } + axios.get('/api/search', { + params: { + 'q': this.query, + 'src': 'metro', + 'v': 2, + 'scope': 'all', + 'page': this.placesCursor + } + }).then(res => { + let results = res.data; + this.results.places = results.places ? results.places : []; + this.placesCache.push(...results.places); + this.loading = false; + }).catch(err => { + this.loading = false; + console.log(err); + this.networkError = true; + }); + + }, + + formatCount(num) { + let count = window.App.util.format.count(num); + return count; } } diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 6760f3359..cef317ce2 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -162,7 +162,8 @@
-

+

+

@@ -196,7 +197,7 @@ - + @@ -411,7 +412,7 @@

{{s.favourites_count == 1 ? '1 like' : s.favourites_count+' likes'}} - +

@@ -922,7 +923,7 @@ }, - likeStatus(status) { + likeStatus(status, event) { if($('body').hasClass('loggedIn') == false) { return; } @@ -937,6 +938,12 @@ status.favourites_count = count; swal('Error', 'Something went wrong, please try again later.', 'error'); }); + window.navigator.vibrate(200); + if(status.favourited) { + setTimeout(function() { + event.target.classList.add('animate__animated', 'animate__bounce'); + },100); + } }, shareStatus(status, $event) {