logo

pleroma-fe

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

notification.js (4966B)


  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. betterShadow: this.$store.state.interface.browserSupport.cssFilter,
  45. unmuted: false,
  46. showingApproveConfirmDialog: false,
  47. showingDenyConfirmDialog: false
  48. }
  49. },
  50. props: ['notification'],
  51. emits: ['interacted'],
  52. components: {
  53. StatusContent,
  54. UserAvatar,
  55. UserCard,
  56. Timeago,
  57. Status,
  58. Report,
  59. RichContent,
  60. UserPopover,
  61. UserLink,
  62. ConfirmModal
  63. },
  64. methods: {
  65. toggleStatusExpanded () {
  66. this.statusExpanded = !this.statusExpanded
  67. },
  68. generateUserProfileLink (user) {
  69. return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
  70. },
  71. getUser (notification) {
  72. return this.$store.state.users.usersObject[notification.from_profile.id]
  73. },
  74. interacted () {
  75. this.$emit('interacted')
  76. },
  77. toggleMute () {
  78. this.unmuted = !this.unmuted
  79. },
  80. showApproveConfirmDialog () {
  81. this.showingApproveConfirmDialog = true
  82. },
  83. hideApproveConfirmDialog () {
  84. this.showingApproveConfirmDialog = false
  85. },
  86. showDenyConfirmDialog () {
  87. this.showingDenyConfirmDialog = true
  88. },
  89. hideDenyConfirmDialog () {
  90. this.showingDenyConfirmDialog = false
  91. },
  92. approveUser () {
  93. if (this.shouldConfirmApprove) {
  94. this.showApproveConfirmDialog()
  95. } else {
  96. this.doApprove()
  97. }
  98. },
  99. doApprove () {
  100. this.$emit('interacted')
  101. this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
  102. this.$store.dispatch('removeFollowRequest', this.user)
  103. this.$store.dispatch('markSingleNotificationAsSeen', { id: this.notification.id })
  104. this.$store.dispatch('updateNotification', {
  105. id: this.notification.id,
  106. updater: notification => {
  107. notification.type = 'follow'
  108. }
  109. })
  110. this.hideApproveConfirmDialog()
  111. },
  112. denyUser () {
  113. if (this.shouldConfirmDeny) {
  114. this.showDenyConfirmDialog()
  115. } else {
  116. this.doDeny()
  117. }
  118. },
  119. doDeny () {
  120. this.$emit('interacted')
  121. this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
  122. .then(() => {
  123. this.$store.dispatch('dismissNotificationLocal', { id: this.notification.id })
  124. this.$store.dispatch('removeFollowRequest', this.user)
  125. })
  126. this.hideDenyConfirmDialog()
  127. }
  128. },
  129. computed: {
  130. userClass () {
  131. return highlightClass(this.notification.from_profile)
  132. },
  133. userStyle () {
  134. const highlight = this.$store.getters.mergedConfig.highlight
  135. const user = this.notification.from_profile
  136. return highlightStyle(highlight[user.screen_name])
  137. },
  138. user () {
  139. return this.$store.getters.findUser(this.notification.from_profile.id)
  140. },
  141. userProfileLink () {
  142. return this.generateUserProfileLink(this.user)
  143. },
  144. targetUser () {
  145. return this.$store.getters.findUser(this.notification.target.id)
  146. },
  147. targetUserProfileLink () {
  148. return this.generateUserProfileLink(this.targetUser)
  149. },
  150. needMute () {
  151. return this.$store.getters.relationship(this.user.id).muting
  152. },
  153. isStatusNotification () {
  154. return isStatusNotification(this.notification.type)
  155. },
  156. mergedConfig () {
  157. return this.$store.getters.mergedConfig
  158. },
  159. shouldConfirmApprove () {
  160. return this.mergedConfig.modalOnApproveFollow
  161. },
  162. shouldConfirmDeny () {
  163. return this.mergedConfig.modalOnDenyFollow
  164. },
  165. ...mapState({
  166. currentUser: state => state.users.currentUser
  167. })
  168. }
  169. }
  170. export default Notification