mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-12 17:44:31 +00:00
Update Post component, adding follow and unfollow methods.
This commit is contained in:
parent
a1e162f095
commit
4508697563
1 changed files with 26 additions and 0 deletions
|
@ -37,6 +37,8 @@
|
||||||
v-on:bookmark="handleBookmark()"
|
v-on:bookmark="handleBookmark()"
|
||||||
v-on:share="shareStatus()"
|
v-on:share="shareStatus()"
|
||||||
v-on:unshare="unshareStatus()"
|
v-on:unshare="unshareStatus()"
|
||||||
|
v-on:follow="follow()"
|
||||||
|
v-on:unfollow="unfollow()"
|
||||||
v-on:counter-change="counterChange"
|
v-on:counter-change="counterChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -333,6 +335,30 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
follow() {
|
||||||
|
axios.post('/api/v1/accounts/' + this.post.account.id + '/follow')
|
||||||
|
.then(res => {
|
||||||
|
this.$store.commit('updateRelationship', [res.data]);
|
||||||
|
this.user.following_count++;
|
||||||
|
this.post.account.followers_count++;
|
||||||
|
}).catch(err => {
|
||||||
|
swal('Oops!', 'An error occurred when attempting to follow this account.', 'error');
|
||||||
|
this.post.relationship.following = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
unfollow() {
|
||||||
|
axios.post('/api/v1/accounts/' + this.post.account.id + '/unfollow')
|
||||||
|
.then(res => {
|
||||||
|
this.$store.commit('updateRelationship', [res.data]);
|
||||||
|
this.user.following_count--;
|
||||||
|
this.post.account.followers_count--;
|
||||||
|
}).catch(err => {
|
||||||
|
swal('Oops!', 'An error occurred when attempting to unfollow this account.', 'error');
|
||||||
|
this.post.relationship.following = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
openContextMenu() {
|
openContextMenu() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.contextMenu.open();
|
this.$refs.contextMenu.open();
|
||||||
|
|
Loading…
Reference in a new issue