logo

pleroma-fe

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

side_drawer.js (3552B)


  1. import { mapState, mapGetters } from 'vuex'
  2. import { mapState as mapPiniaState } from 'pinia'
  3. import UserCard from '../user_card/user_card.vue'
  4. import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
  5. import GestureService from '../../services/gesture_service/gesture_service'
  6. import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js'
  7. import { library } from '@fortawesome/fontawesome-svg-core'
  8. import {
  9. faSignInAlt,
  10. faSignOutAlt,
  11. faHome,
  12. faComments,
  13. faBell,
  14. faUserPlus,
  15. faBullhorn,
  16. faSearch,
  17. faTachometerAlt,
  18. faCog,
  19. faInfoCircle,
  20. faCompass,
  21. faList,
  22. faFilePen
  23. } from '@fortawesome/free-solid-svg-icons'
  24. import { useShoutStore } from 'src/stores/shout'
  25. import { useInterfaceStore } from 'src/stores/interface'
  26. import { useAnnouncementsStore } from 'src/stores/announcements'
  27. library.add(
  28. faSignInAlt,
  29. faSignOutAlt,
  30. faHome,
  31. faComments,
  32. faBell,
  33. faUserPlus,
  34. faBullhorn,
  35. faSearch,
  36. faTachometerAlt,
  37. faCog,
  38. faInfoCircle,
  39. faCompass,
  40. faList,
  41. faFilePen
  42. )
  43. const SideDrawer = {
  44. props: ['logout'],
  45. data: () => ({
  46. closed: true,
  47. closeGesture: undefined
  48. }),
  49. created () {
  50. this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer)
  51. if (this.currentUser && this.currentUser.locked) {
  52. this.$store.dispatch('startFetchingFollowRequests')
  53. }
  54. },
  55. components: { UserCard },
  56. computed: {
  57. currentUser () {
  58. return this.$store.state.users.currentUser
  59. },
  60. shout () { return useShoutStore().joined },
  61. unseenNotifications () {
  62. return unseenNotificationsFromStore(this.$store)
  63. },
  64. unseenNotificationsCount () {
  65. return this.unseenNotifications.length
  66. },
  67. suggestionsEnabled () {
  68. return this.$store.state.instance.suggestionsEnabled
  69. },
  70. logo () {
  71. return this.$store.state.instance.logo
  72. },
  73. hideSitename () {
  74. return this.$store.state.instance.hideSitename
  75. },
  76. sitename () {
  77. return this.$store.state.instance.name
  78. },
  79. followRequestCount () {
  80. return this.$store.state.api.followRequests.length
  81. },
  82. privateMode () {
  83. return this.$store.state.instance.private
  84. },
  85. federating () {
  86. return this.$store.state.instance.federating
  87. },
  88. timelinesRoute () {
  89. let name
  90. if (useInterfaceStore().lastTimeline) {
  91. name = useInterfaceStore().lastTimeline
  92. }
  93. name = this.currentUser ? 'friends' : 'public-timeline'
  94. if (USERNAME_ROUTES.has(name)) {
  95. return { name, params: { username: this.currentUser.screen_name } }
  96. } else {
  97. return { name }
  98. }
  99. },
  100. ...mapPiniaState(useAnnouncementsStore, {
  101. supportsAnnouncements: store => store.supportsAnnouncements,
  102. unreadAnnouncementCount: 'unreadAnnouncementCount'
  103. }),
  104. ...mapState({
  105. pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
  106. }),
  107. ...mapGetters(['unreadChatCount', 'draftCount'])
  108. },
  109. methods: {
  110. toggleDrawer () {
  111. this.closed = !this.closed
  112. },
  113. doLogout () {
  114. this.logout()
  115. this.toggleDrawer()
  116. },
  117. touchStart (e) {
  118. GestureService.beginSwipe(e, this.closeGesture)
  119. },
  120. touchMove (e) {
  121. GestureService.updateSwipe(e, this.closeGesture)
  122. },
  123. openSettingsModal () {
  124. useInterfaceStore().openSettingsModal('user')
  125. },
  126. openAdminModal () {
  127. useInterfaceStore().openSettingsModal('admin')
  128. }
  129. }
  130. }
  131. export default SideDrawer