logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

follow_request_card.js (2520B)


  1. import BasicUserCard from '../basic_user_card/basic_user_card.vue'
  2. import ConfirmModal from '../confirm_modal/confirm_modal.vue'
  3. import { notificationsFromStore } from '../../services/notification_utils/notification_utils.js'
  4. const FollowRequestCard = {
  5. props: ['user'],
  6. components: {
  7. BasicUserCard,
  8. ConfirmModal
  9. },
  10. data () {
  11. return {
  12. showingApproveConfirmDialog: false,
  13. showingDenyConfirmDialog: false
  14. }
  15. },
  16. methods: {
  17. findFollowRequestNotificationId () {
  18. const notif = notificationsFromStore(this.$store).find(
  19. (notif) => notif.from_profile.id === this.user.id && notif.type === 'follow_request'
  20. )
  21. return notif && notif.id
  22. },
  23. showApproveConfirmDialog () {
  24. this.showingApproveConfirmDialog = true
  25. },
  26. hideApproveConfirmDialog () {
  27. this.showingApproveConfirmDialog = false
  28. },
  29. showDenyConfirmDialog () {
  30. this.showingDenyConfirmDialog = true
  31. },
  32. hideDenyConfirmDialog () {
  33. this.showingDenyConfirmDialog = false
  34. },
  35. approveUser () {
  36. if (this.shouldConfirmApprove) {
  37. this.showApproveConfirmDialog()
  38. } else {
  39. this.doApprove()
  40. }
  41. },
  42. doApprove () {
  43. this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
  44. this.$store.dispatch('removeFollowRequest', this.user)
  45. const notifId = this.findFollowRequestNotificationId()
  46. this.$store.dispatch('markSingleNotificationAsSeen', { id: notifId })
  47. this.$store.dispatch('updateNotification', {
  48. id: notifId,
  49. updater: notification => {
  50. notification.type = 'follow'
  51. }
  52. })
  53. this.hideApproveConfirmDialog()
  54. },
  55. denyUser () {
  56. if (this.shouldConfirmDeny) {
  57. this.showDenyConfirmDialog()
  58. } else {
  59. this.doDeny()
  60. }
  61. },
  62. doDeny () {
  63. const notifId = this.findFollowRequestNotificationId()
  64. this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
  65. .then(() => {
  66. this.$store.dispatch('dismissNotificationLocal', { id: notifId })
  67. this.$store.dispatch('removeFollowRequest', this.user)
  68. })
  69. this.hideDenyConfirmDialog()
  70. }
  71. },
  72. computed: {
  73. mergedConfig () {
  74. return this.$store.getters.mergedConfig
  75. },
  76. shouldConfirmApprove () {
  77. return this.mergedConfig.modalOnApproveFollow
  78. },
  79. shouldConfirmDeny () {
  80. return this.mergedConfig.modalOnDenyFollow
  81. }
  82. }
  83. }
  84. export default FollowRequestCard