diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-02-11 13:29:58 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-02-11 13:29:58 +0000 |
| commit | 0e6134b32e820deeb947aa5e9e0401eecfc80bba (patch) | |
| tree | afaa6a9dd424bd3a1161437944f8f7e84d558250 /src/components/user_card/user_card.js | |
| parent | e1e9e50b981fe6507886cae26603e4fcf9b5af75 (diff) | |
| parent | 4b18989fefba1f80c5788325b0f7e9906b5ac48b (diff) | |
Merge branch 'issue-332-update-follow-tabs' into 'develop'
#332 - add follow/not follow button to follow list
See merge request pleroma/pleroma-fe!558
Diffstat (limited to 'src/components/user_card/user_card.js')
| -rw-r--r-- | src/components/user_card/user_card.js | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index ecc36a4d..a4c84716 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -1,16 +1,21 @@ import UserCardContent from '../user_card_content/user_card_content.vue' import UserAvatar from '../user_avatar/user_avatar.vue' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' const UserCard = { props: [ 'user', 'showFollows', - 'showApproval' + 'showApproval', + 'showActions' ], data () { return { - userExpanded: false + userExpanded: false, + followRequestInProgress: false, + followRequestSent: false, + updated: false } }, components: { @@ -18,7 +23,11 @@ const UserCard = { UserAvatar }, computed: { - currentUser () { return this.$store.state.users.currentUser } + currentUser () { return this.$store.state.users.currentUser }, + following () { return this.updated ? this.updated.following : this.user.following }, + showFollow () { + return this.showActions && (!this.showFollows && !this.following || this.updated && !this.updated.following) + } }, methods: { toggleUserExpanded () { @@ -34,6 +43,21 @@ const UserCard = { }, userProfileLink (user) { return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames) + }, + followUser () { + this.followRequestInProgress = true + requestFollow(this.user, this.$store).then(({ sent, updated }) => { + this.followRequestInProgress = false + this.followRequestSent = sent + this.updated = updated + }) + }, + unfollowUser () { + this.followRequestInProgress = true + requestUnfollow(this.user, this.$store).then(({ updated }) => { + this.followRequestInProgress = false + this.updated = updated + }) } } } |
