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

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-02-26 04:34:24 +00:00
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
import { notificationsFromStore } from '../../services/notification_utils/notification_utils.js'
2019-02-26 04:34:24 +00:00
const FollowRequestCard = {
props: ['user'],
components: {
BasicUserCard
},
methods: {
findFollowRequestNotificationId () {
const notif = notificationsFromStore(this.$store).find(
(notif) => notif.from_profile.id === this.user.id && notif.type === 'follow_request'
)
return notif && notif.id
},
2019-02-26 04:34:24 +00:00
approveUser () {
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
2019-02-26 04:34:24 +00:00
this.$store.dispatch('removeFollowRequest', this.user)
const notifId = this.findFollowRequestNotificationId()
this.$store.dispatch('updateNotification', {
id: notifId,
updater: notification => {
notification.type = 'follow'
notification.seen = true
}
})
2019-02-26 04:34:24 +00:00
},
denyUser () {
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
2019-02-26 04:34:24 +00:00
this.$store.dispatch('removeFollowRequest', this.user)
const notifId = this.findFollowRequestNotificationId()
this.$store.dispatch('dismissNotification', { id: notifId })
2019-02-26 04:34:24 +00:00
}
}
}
export default FollowRequestCard