logo

pleroma-fe

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

notification.js (4892B)


  1. import StatusContent from '../status_content/status_content.vue'
  2. import { mapState } from 'vuex'
  3. import Status from '../status/status.vue'
  4. import UserAvatar from '../user_avatar/user_avatar.vue'
  5. import UserCard from '../user_card/user_card.vue'
  6. import Timeago from '../timeago/timeago.vue'
  7. import Report from '../report/report.vue'
  8. import UserLink from '../user_link/user_link.vue'
  9. import RichContent from 'src/components/rich_content/rich_content.jsx'
  10. import UserPopover from '../user_popover/user_popover.vue'
  11. import ConfirmModal from '../confirm_modal/confirm_modal.vue'
  12. import { isStatusNotification } from '../../services/notification_utils/notification_utils.js'
  13. import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
  14. import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
  15. import { library } from '@fortawesome/fontawesome-svg-core'
  16. import {
  17. faCheck,
  18. faTimes,
  19. faStar,
  20. faRetweet,
  21. faUserPlus,
  22. faEyeSlash,
  23. faUser,
  24. faSuitcaseRolling,
  25. faExpandAlt,
  26. faCompressAlt
  27. } from '@fortawesome/free-solid-svg-icons'
  28. library.add(
  29. faCheck,
  30. faTimes,
  31. faStar,
  32. faRetweet,
  33. faUserPlus,
  34. faUser,
  35. faEyeSlash,
  36. faSuitcaseRolling,
  37. faExpandAlt,
  38. faCompressAlt
  39. )
  40. const Notification = {
  41. data () {
  42. return {
  43. statusExpanded: false,
  44. unmuted: false,
  45. showingApproveConfirmDialog: false,
  46. showingDenyConfirmDialog: false
  47. }
  48. },
  49. props: ['notification'],
  50. emits: ['interacted'],
  51. components: {
  52. StatusContent,
  53. UserAvatar,
  54. UserCard,
  55. Timeago,
  56. Status,
  57. Report,
  58. RichContent,
  59. UserPopover,
  60. UserLink,
  61. ConfirmModal
  62. },
  63. methods: {
  64. toggleStatusExpanded () {
  65. this.statusExpanded = !this.statusExpanded
  66. },
  67. generateUserProfileLink (user) {
  68. return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
  69. },
  70. getUser (notification) {
  71. return this.$store.state.users.usersObject[notification.from_profile.id]
  72. },
  73. interacted () {
  74. this.$emit('interacted')
  75. },
  76. toggleMute () {
  77. this.unmuted = !this.unmuted
  78. },
  79. showApproveConfirmDialog () {
  80. this.showingApproveConfirmDialog = true
  81. },
  82. hideApproveConfirmDialog () {
  83. this.showingApproveConfirmDialog = false
  84. },
  85. showDenyConfirmDialog () {
  86. this.showingDenyConfirmDialog = true
  87. },
  88. hideDenyConfirmDialog () {
  89. this.showingDenyConfirmDialog = false
  90. },
  91. approveUser () {
  92. if (this.shouldConfirmApprove) {
  93. this.showApproveConfirmDialog()
  94. } else {
  95. this.doApprove()
  96. }
  97. },
  98. doApprove () {
  99. this.$emit('interacted')
  100. this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
  101. this.$store.dispatch('removeFollowRequest', this.user)
  102. this.$store.dispatch('markSingleNotificationAsSeen', { id: this.notification.id })
  103. this.$store.dispatch('updateNotification', {
  104. id: this.notification.id,
  105. updater: notification => {
  106. notification.type = 'follow'
  107. }
  108. })
  109. this.hideApproveConfirmDialog()
  110. },
  111. denyUser () {
  112. if (this.shouldConfirmDeny) {
  113. this.showDenyConfirmDialog()
  114. } else {
  115. this.doDeny()
  116. }
  117. },
  118. doDeny () {
  119. this.$emit('interacted')
  120. this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
  121. .then(() => {
  122. this.$store.dispatch('dismissNotificationLocal', { id: this.notification.id })
  123. this.$store.dispatch('removeFollowRequest', this.user)
  124. })
  125. this.hideDenyConfirmDialog()
  126. }
  127. },
  128. computed: {
  129. userClass () {
  130. return highlightClass(this.notification.from_profile)
  131. },
  132. userStyle () {
  133. const highlight = this.$store.getters.mergedConfig.highlight
  134. const user = this.notification.from_profile
  135. return highlightStyle(highlight[user.screen_name])
  136. },
  137. user () {
  138. return this.$store.getters.findUser(this.notification.from_profile.id)
  139. },
  140. userProfileLink () {
  141. return this.generateUserProfileLink(this.user)
  142. },
  143. targetUser () {
  144. return this.$store.getters.findUser(this.notification.target.id)
  145. },
  146. targetUserProfileLink () {
  147. return this.generateUserProfileLink(this.targetUser)
  148. },
  149. needMute () {
  150. return this.$store.getters.relationship(this.user.id).muting
  151. },
  152. isStatusNotification () {
  153. return isStatusNotification(this.notification.type)
  154. },
  155. mergedConfig () {
  156. return this.$store.getters.mergedConfig
  157. },
  158. shouldConfirmApprove () {
  159. return this.mergedConfig.modalOnApproveFollow
  160. },
  161. shouldConfirmDeny () {
  162. return this.mergedConfig.modalOnDenyFollow
  163. },
  164. ...mapState({
  165. currentUser: state => state.users.currentUser
  166. })
  167. }
  168. }
  169. export default Notification