logo

pleroma-fe

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

mute_confirm.js (2956B)


  1. import { unitToSeconds } from 'src/services/date_utils/date_utils.js'
  2. import { mapGetters } from 'vuex'
  3. import ConfirmModal from './confirm_modal.vue'
  4. import Select from 'src/components/select/select.vue'
  5. export default {
  6. props: ['type', 'user'],
  7. emits: ['hide', 'show', 'muted'],
  8. data: () => ({
  9. showing: false,
  10. muteExpiryAmount: 2,
  11. muteExpiryUnit: 'hours'
  12. }),
  13. components: {
  14. ConfirmModal,
  15. Select
  16. },
  17. computed: {
  18. muteExpiryValue () {
  19. unitToSeconds(this.muteExpiryUnit, this.muteExpiryAmount)
  20. },
  21. muteExpiryUnits () {
  22. return ['minutes', 'hours', 'days']
  23. },
  24. domain () {
  25. return this.user.fqn.split('@')[1]
  26. },
  27. keypath () {
  28. if (this.type === 'domain') {
  29. return 'status.mute_domain_confirm'
  30. } else if (this.type === 'conversation') {
  31. return 'status.mute_conversation_confirm'
  32. } else {
  33. return 'user_card.mute_confirm'
  34. }
  35. },
  36. userIsMuted () {
  37. return this.$store.getters.relationship(this.user.id).muting
  38. },
  39. conversationIsMuted () {
  40. return this.status.conversation_muted
  41. },
  42. domainIsMuted () {
  43. return new Set(this.$store.state.users.currentUser.domainMutes).has(this.domain)
  44. },
  45. shouldConfirm () {
  46. switch (this.type) {
  47. case 'domain': {
  48. return this.mergedConfig.modalOnMuteDomain
  49. }
  50. case 'conversation': {
  51. return this.mergedConfig.modalOnMuteConversation
  52. }
  53. default: {
  54. return this.mergedConfig.modalOnMute
  55. }
  56. }
  57. },
  58. ...mapGetters(['mergedConfig'])
  59. },
  60. methods: {
  61. optionallyPrompt () {
  62. console.log('Triggered')
  63. if (this.shouldConfirm) {
  64. console.log('SHAWN!!')
  65. this.show()
  66. } else {
  67. this.doMute()
  68. }
  69. },
  70. show () {
  71. this.showing = true
  72. this.$emit('show')
  73. },
  74. hide () {
  75. this.showing = false
  76. this.$emit('hide')
  77. },
  78. doMute () {
  79. switch (this.type) {
  80. case 'domain': {
  81. if (!this.domainIsMuted) {
  82. this.$store.dispatch('muteDomain', { id: this.domain, expiresIn: this.muteExpiryValue })
  83. } else {
  84. this.$store.dispatch('unmuteDomain', { id: this.domain })
  85. }
  86. break
  87. }
  88. case 'conversation': {
  89. if (!this.conversationIsMuted) {
  90. this.$store.dispatch('muteConversation', { id: this.status.id, expiresIn: this.muteExpiryValue })
  91. } else {
  92. this.$store.dispatch('unmuteConversation', { id: this.status.id })
  93. }
  94. break
  95. }
  96. default: {
  97. if (!this.userIsMuted) {
  98. this.$store.dispatch('muteUser', { id: this.user.id, expiresIn: this.muteExpiryValue })
  99. } else {
  100. this.$store.dispatch('unmuteUser', { id: this.user.id })
  101. }
  102. break
  103. }
  104. }
  105. this.$emit('muted')
  106. this.hide()
  107. }
  108. }
  109. }