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