logo

pleroma-fe

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

follow_button.js (2270B)


  1. import ConfirmModal from '../confirm_modal/confirm_modal.vue'
  2. import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'
  3. export default {
  4. props: ['relationship', 'user', 'labelFollowing', 'buttonClass'],
  5. components: {
  6. ConfirmModal
  7. },
  8. data () {
  9. return {
  10. inProgress: false,
  11. showingConfirmUnfollow: false
  12. }
  13. },
  14. computed: {
  15. shouldConfirmUnfollow () {
  16. return this.$store.getters.mergedConfig.modalOnUnfollow
  17. },
  18. isPressed () {
  19. return this.inProgress || this.relationship.following
  20. },
  21. title () {
  22. if (this.inProgress || this.relationship.following) {
  23. return this.$t('user_card.follow_unfollow')
  24. } else if (this.relationship.requested) {
  25. return this.$t('user_card.follow_cancel')
  26. } else {
  27. return this.$t('user_card.follow')
  28. }
  29. },
  30. label () {
  31. if (this.inProgress) {
  32. return this.$t('user_card.follow_progress')
  33. } else if (this.relationship.following) {
  34. return this.labelFollowing || this.$t('user_card.following')
  35. } else if (this.relationship.requested) {
  36. return this.$t('user_card.follow_sent')
  37. } else {
  38. return this.$t('user_card.follow')
  39. }
  40. },
  41. disabled () {
  42. return this.inProgress || this.user.deactivated
  43. }
  44. },
  45. methods: {
  46. showConfirmUnfollow () {
  47. this.showingConfirmUnfollow = true
  48. },
  49. hideConfirmUnfollow () {
  50. this.showingConfirmUnfollow = false
  51. },
  52. onClick () {
  53. this.relationship.following || this.relationship.requested ? this.unfollow() : this.follow()
  54. },
  55. follow () {
  56. this.inProgress = true
  57. requestFollow(this.relationship.id, this.$store).then(() => {
  58. this.inProgress = false
  59. })
  60. },
  61. unfollow () {
  62. if (this.shouldConfirmUnfollow) {
  63. this.showConfirmUnfollow()
  64. } else {
  65. this.doUnfollow()
  66. }
  67. },
  68. doUnfollow () {
  69. const store = this.$store
  70. this.inProgress = true
  71. requestUnfollow(this.relationship.id, store).then(() => {
  72. this.inProgress = false
  73. store.commit('removeStatus', { timeline: 'friends', userId: this.relationship.id })
  74. })
  75. this.hideConfirmUnfollow()
  76. }
  77. }
  78. }