2019-02-25 20:34:24 -08:00
|
|
|
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
2020-05-02 00:19:47 -07:00
|
|
|
import { notificationsFromStore } from '../../services/notification_utils/notification_utils.js'
|
2019-02-25 20:34:24 -08:00
|
|
|
|
|
|
|
const FollowRequestCard = {
|
|
|
|
props: ['user'],
|
|
|
|
components: {
|
|
|
|
BasicUserCard
|
|
|
|
},
|
|
|
|
methods: {
|
2020-05-02 00:19:47 -07:00
|
|
|
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-25 20:34:24 -08:00
|
|
|
approveUser () {
|
2019-11-24 03:57:46 -08:00
|
|
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
2019-02-25 20:34:24 -08:00
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
2020-05-02 00:19:47 -07:00
|
|
|
|
|
|
|
const notifId = this.findFollowRequestNotificationId()
|
2020-05-02 00:52:57 -07:00
|
|
|
this.$store.dispatch('markSingleNotificationAsSeen', { id: notifId })
|
2020-05-02 00:19:47 -07:00
|
|
|
this.$store.dispatch('updateNotification', {
|
|
|
|
id: notifId,
|
|
|
|
updater: notification => {
|
|
|
|
notification.type = 'follow'
|
|
|
|
}
|
|
|
|
})
|
2019-02-25 20:34:24 -08:00
|
|
|
},
|
|
|
|
denyUser () {
|
2019-11-24 03:57:46 -08:00
|
|
|
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
|
2019-02-25 20:34:24 -08:00
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
2020-05-02 00:19:47 -07:00
|
|
|
|
|
|
|
const notifId = this.findFollowRequestNotificationId()
|
|
|
|
this.$store.dispatch('dismissNotification', { id: notifId })
|
2019-02-25 20:34:24 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FollowRequestCard
|