follow requests: refactor to properly leverage vuex
This commit is contained in:
parent
fd25f68741
commit
7389f07115
3 changed files with 23 additions and 8 deletions
|
@ -1,17 +1,22 @@
|
|||
import UserCard from '../user_card/user_card.vue'
|
||||
|
||||
const FollowRequests = {
|
||||
data () {
|
||||
return {
|
||||
requests: []
|
||||
}
|
||||
},
|
||||
components: {
|
||||
UserCard
|
||||
},
|
||||
created () {
|
||||
this.$store.state.api.backendInteractor.fetchFollowRequests()
|
||||
.then((requests) => { this.requests = requests })
|
||||
this.updateRequests()
|
||||
},
|
||||
computed: {
|
||||
requests () {
|
||||
return this.$store.state.api.followRequests
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateRequests () {
|
||||
this.$store.state.api.backendInteractor.fetchFollowRequests()
|
||||
.then((requests) => { this.$store.commit('setFollowRequests', requests) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ const UserCard = {
|
|||
},
|
||||
approveUser () {
|
||||
this.$store.state.api.backendInteractor.approveUser(this.user.id)
|
||||
this.$store.dispatch('removeFollowRequest', this.user)
|
||||
},
|
||||
denyUser () {
|
||||
this.$store.state.api.backendInteractor.denyUser(this.user.id)
|
||||
this.$store.dispatch('removeFollowRequest', this.user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue