diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 9aec62985..4fc5984a9 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -484,8 +484,6 @@ size="sm" body-class="list-group-flush p-0 rounded">
@@ -397,7 +397,7 @@
@@ -1049,19 +1049,22 @@ if($('body').hasClass('loggedIn') == false) { return; } - axios.post('/i/follow', { - item: this.profileId - }).then(res => { - this.$refs.visitorContextMenu.hide(); - if(this.relationship.following) { + this.$refs.visitorContextMenu.hide(); + const curState = this.relationship.following; + const apiUrl = curState ? + '/api/v1/accounts/' + this.profileId + '/unfollow' : + '/api/v1/accounts/' + this.profileId + '/follow'; + axios.post(apiUrl) + .then(res => { + if(curState) { this.profile.followers_count--; - if(this.profile.locked == true) { - window.location.href = '/'; + if(this.profile.locked) { + location.reload(); } } else { this.profile.followers_count++; } - this.relationship.following = !this.relationship.following; + this.relationship = res.data; }).catch(err => { if(err.response.data.message) { swal('Error', err.response.data.message, 'error'); @@ -1218,9 +1221,11 @@ }, followModalAction(id, index, type = 'following') { - axios.post('/i/follow', { - item: id - }).then(res => { + const apiUrl = type === 'following' ? + '/api/v1/accounts/' + id + '/unfollow' : + '/api/v1/accounts/' + id + '/follow'; + axios.post(apiUrl) + .then(res => { if(type == 'following') { this.following.splice(index, 1); this.profile.following_count--; diff --git a/resources/assets/js/components/SearchResults.vue b/resources/assets/js/components/SearchResults.vue index a29f3054a..246722b21 100644 --- a/resources/assets/js/components/SearchResults.vue +++ b/resources/assets/js/components/SearchResults.vue @@ -379,26 +379,6 @@ export default { this.searchContext(this.analysis); }, - followProfile(profile, index) { - this.loading = true; - axios.post('/i/follow', { - item: profile.entity.id - }).then(res => { - if(profile.entity.local == true) { - this.fetchSearchResults(); - return; - } else { - this.loading = false; - this.results.profiles[index].entity.follow_request = true; - return; - } - }).catch(err => { - if(err.response.data.message) { - swal('Error', err.response.data.message, 'error'); - } - }); - }, - searchLexer() { let q = this.query; diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 62358c218..333561567 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -283,21 +283,21 @@
{{formatCount(profile.statuses_count)}}
+Posts
+ + +{{formatCount(profile.followers_count)}}
+Followers
+ + +{{formatCount(profile.following_count)}}
+Following
+ +{{rec.message}}