akkoma-fe/src/components/follow_card/follow_card.js

46 lines
1,020 B
JavaScript
Raw Normal View History

2019-02-26 03:51:04 +00:00
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
import RemoteFollow from '../remote_follow/remote_follow.vue'
2019-02-26 03:51:04 +00:00
import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'
const FollowCard = {
props: [
'user',
'noFollowsYou'
],
data () {
return {
2019-02-26 15:14:12 +00:00
inProgress: false,
requestSent: false
2019-02-26 03:51:04 +00:00
}
},
components: {
BasicUserCard,
RemoteFollow
2019-02-26 03:51:04 +00:00
},
computed: {
isMe () {
return this.$store.state.users.currentUser.id === this.user.id
},
loggedIn () {
return this.$store.state.users.currentUser
2019-02-26 03:51:04 +00:00
}
},
methods: {
followUser () {
2019-02-26 15:14:12 +00:00
this.inProgress = true
requestFollow(this.user, this.$store).then(({ sent }) => {
2019-02-26 15:14:12 +00:00
this.inProgress = false
2019-02-26 03:51:04 +00:00
this.requestSent = sent
})
},
unfollowUser () {
2019-02-26 15:14:12 +00:00
this.inProgress = true
requestUnfollow(this.user, this.$store).then(() => {
2019-02-26 15:14:12 +00:00
this.inProgress = false
2019-02-26 03:51:04 +00:00
})
}
}
}
export default FollowCard