logo

pleroma-fe

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

nav_panel.js (3780B)


  1. import ListsMenuContent from 'src/components/lists_menu/lists_menu_content.vue'
  2. import { mapState, mapGetters } from 'vuex'
  3. import { TIMELINES, ROOT_ITEMS } from 'src/components/navigation/navigation.js'
  4. import { filterNavigation } from 'src/components/navigation/filter.js'
  5. import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
  6. import NavigationPins from 'src/components/navigation/navigation_pins.vue'
  7. import Checkbox from 'src/components/checkbox/checkbox.vue'
  8. import { library } from '@fortawesome/fontawesome-svg-core'
  9. import {
  10. faUsers,
  11. faGlobe,
  12. faBookmark,
  13. faEnvelope,
  14. faChevronDown,
  15. faChevronUp,
  16. faComments,
  17. faBell,
  18. faInfoCircle,
  19. faStream,
  20. faList,
  21. faBullhorn
  22. } from '@fortawesome/free-solid-svg-icons'
  23. library.add(
  24. faUsers,
  25. faGlobe,
  26. faBookmark,
  27. faEnvelope,
  28. faChevronDown,
  29. faChevronUp,
  30. faComments,
  31. faBell,
  32. faInfoCircle,
  33. faStream,
  34. faList,
  35. faBullhorn
  36. )
  37. const NavPanel = {
  38. props: ['forceExpand', 'forceEditMode'],
  39. created () {
  40. },
  41. components: {
  42. ListsMenuContent,
  43. NavigationEntry,
  44. NavigationPins,
  45. Checkbox
  46. },
  47. data () {
  48. return {
  49. editMode: false,
  50. showTimelines: false,
  51. showLists: false,
  52. timelinesList: Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
  53. rootList: Object.entries(ROOT_ITEMS).map(([k, v]) => ({ ...v, name: k }))
  54. }
  55. },
  56. methods: {
  57. toggleTimelines () {
  58. this.showTimelines = !this.showTimelines
  59. },
  60. toggleLists () {
  61. this.showLists = !this.showLists
  62. },
  63. toggleEditMode () {
  64. this.editMode = !this.editMode
  65. },
  66. toggleCollapse () {
  67. this.$store.commit('setPreference', { path: 'simple.collapseNav', value: !this.collapsed })
  68. this.$store.dispatch('pushServerSideStorage')
  69. },
  70. isPinned (item) {
  71. return this.pinnedItems.has(item)
  72. },
  73. togglePin (item) {
  74. if (this.isPinned(item)) {
  75. this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
  76. } else {
  77. this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
  78. }
  79. this.$store.dispatch('pushServerSideStorage')
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. currentUser: state => state.users.currentUser,
  85. followRequestCount: state => state.api.followRequests.length,
  86. privateMode: state => state.instance.private,
  87. federating: state => state.instance.federating,
  88. pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
  89. supportsAnnouncements: state => state.announcements.supportsAnnouncements,
  90. pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems),
  91. collapsed: state => state.serverSideStorage.prefsStorage.simple.collapseNav
  92. }),
  93. timelinesItems () {
  94. return filterNavigation(
  95. Object
  96. .entries({ ...TIMELINES })
  97. .map(([k, v]) => ({ ...v, name: k })),
  98. {
  99. hasChats: this.pleromaChatMessagesAvailable,
  100. hasAnnouncements: this.supportsAnnouncements,
  101. isFederating: this.federating,
  102. isPrivate: this.privateMode,
  103. currentUser: this.currentUser
  104. }
  105. )
  106. },
  107. rootItems () {
  108. return filterNavigation(
  109. Object
  110. .entries({ ...ROOT_ITEMS })
  111. .map(([k, v]) => ({ ...v, name: k })),
  112. {
  113. hasChats: this.pleromaChatMessagesAvailable,
  114. hasAnnouncements: this.supportsAnnouncements,
  115. isFederating: this.federating,
  116. isPrivate: this.privateMode,
  117. currentUser: this.currentUser
  118. }
  119. )
  120. },
  121. ...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
  122. }
  123. }
  124. export default NavPanel