logo

pleroma-fe

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

navigation_pins.js (3081B)


  1. import { mapState } from 'vuex'
  2. import { mapState as mapPiniaState } from 'pinia'
  3. import { TIMELINES, ROOT_ITEMS, routeTo } from 'src/components/navigation/navigation.js'
  4. import { getBookmarkFolderEntries, getListEntries, filterNavigation } from 'src/components/navigation/filter.js'
  5. import StillImage from 'src/components/still-image/still-image.vue'
  6. import { library } from '@fortawesome/fontawesome-svg-core'
  7. import {
  8. faUsers,
  9. faGlobe,
  10. faBookmark,
  11. faEnvelope,
  12. faComments,
  13. faBell,
  14. faInfoCircle,
  15. faStream,
  16. faList
  17. } from '@fortawesome/free-solid-svg-icons'
  18. import { useListsStore } from 'src/stores/lists'
  19. import { useAnnouncementsStore } from 'src/stores/announcements'
  20. library.add(
  21. faUsers,
  22. faGlobe,
  23. faBookmark,
  24. faEnvelope,
  25. faComments,
  26. faBell,
  27. faInfoCircle,
  28. faStream,
  29. faList
  30. )
  31. const NavPanel = {
  32. props: ['limit'],
  33. methods: {
  34. getRouteTo (item) {
  35. return routeTo(item, this.currentUser)
  36. }
  37. },
  38. components: {
  39. StillImage
  40. },
  41. computed: {
  42. getters () {
  43. return this.$store.getters
  44. },
  45. ...mapPiniaState(useListsStore, {
  46. lists: getListEntries
  47. }),
  48. ...mapPiniaState(useAnnouncementsStore, {
  49. supportsAnnouncements: store => store.supportsAnnouncements
  50. }),
  51. ...mapState({
  52. bookmarks: getBookmarkFolderEntries,
  53. currentUser: state => state.users.currentUser,
  54. followRequestCount: state => state.api.followRequests.length,
  55. privateMode: state => state.instance.private,
  56. federating: state => state.instance.federating,
  57. pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
  58. pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems)
  59. }),
  60. pinnedList () {
  61. if (!this.currentUser) {
  62. return filterNavigation([
  63. { ...TIMELINES.public, name: 'public' },
  64. { ...TIMELINES.twkn, name: 'twkn' },
  65. { ...ROOT_ITEMS.about, name: 'about' }
  66. ],
  67. {
  68. hasChats: this.pleromaChatMessagesAvailable,
  69. hasAnnouncements: this.supportsAnnouncements,
  70. isFederating: this.federating,
  71. isPrivate: this.privateMode,
  72. currentUser: this.currentUser
  73. })
  74. }
  75. return filterNavigation(
  76. [
  77. ...Object
  78. .entries({ ...TIMELINES })
  79. .filter(([k]) => this.pinnedItems.has(k))
  80. .map(([k, v]) => ({ ...v, name: k })),
  81. ...this.lists.filter((k) => this.pinnedItems.has(k.name)),
  82. ...this.bookmarks.filter((k) => this.pinnedItems.has(k.name)),
  83. ...Object
  84. .entries({ ...ROOT_ITEMS })
  85. .filter(([k]) => this.pinnedItems.has(k))
  86. .map(([k, v]) => ({ ...v, name: k }))
  87. ],
  88. {
  89. hasChats: this.pleromaChatMessagesAvailable,
  90. hasAnnouncements: this.supportsAnnouncements,
  91. isFederating: this.federating,
  92. isPrivate: this.privateMode,
  93. currentUser: this.currentUser
  94. }
  95. ).slice(0, this.limit)
  96. }
  97. }
  98. }
  99. export default NavPanel