logo

pleroma-fe

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

timeline_menu.js (2907B)


  1. import Popover from '../popover/popover.vue'
  2. import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
  3. import { mapState } from 'vuex'
  4. import { ListsMenuContent } from '../lists_menu/lists_menu_content.vue'
  5. import { library } from '@fortawesome/fontawesome-svg-core'
  6. import { TIMELINES } from 'src/components/navigation/navigation.js'
  7. import { filterNavigation } from 'src/components/navigation/filter.js'
  8. import {
  9. faChevronDown
  10. } from '@fortawesome/free-solid-svg-icons'
  11. library.add(faChevronDown)
  12. // Route -> i18n key mapping, exported and not in the computed
  13. // because nav panel benefits from the same information.
  14. export const timelineNames = () => {
  15. return {
  16. friends: 'nav.home_timeline',
  17. bookmarks: 'nav.bookmarks',
  18. dms: 'nav.dms',
  19. 'public-timeline': 'nav.public_tl',
  20. 'public-external-timeline': 'nav.twkn',
  21. quotes: 'nav.quotes'
  22. }
  23. }
  24. const TimelineMenu = {
  25. components: {
  26. Popover,
  27. NavigationEntry,
  28. ListsMenuContent
  29. },
  30. data () {
  31. return {
  32. isOpen: false
  33. }
  34. },
  35. created () {
  36. if (timelineNames()[this.$route.name]) {
  37. this.$store.dispatch('setLastTimeline', this.$route.name)
  38. }
  39. },
  40. computed: {
  41. useListsMenu () {
  42. const route = this.$route.name
  43. return route === 'lists-timeline'
  44. },
  45. ...mapState({
  46. currentUser: state => state.users.currentUser,
  47. privateMode: state => state.instance.private,
  48. federating: state => state.instance.federating
  49. }),
  50. timelinesList () {
  51. return filterNavigation(
  52. Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
  53. {
  54. hasChats: this.pleromaChatMessagesAvailable,
  55. isFederating: this.federating,
  56. isPrivate: this.privateMode,
  57. currentUser: this.currentUser
  58. }
  59. )
  60. }
  61. },
  62. methods: {
  63. openMenu () {
  64. // $nextTick is too fast, animation won't play back but
  65. // instead starts in fully open position. Low values
  66. // like 1-5 work on fast machines but not on mobile, 25
  67. // seems like a good compromise that plays without significant
  68. // added lag.
  69. setTimeout(() => {
  70. this.isOpen = true
  71. }, 25)
  72. },
  73. blockOpen (event) {
  74. // For the blank area inside the button element.
  75. // Just setting @click.stop="" makes unintuitive behavior when
  76. // menu is open and clicking on the blank area doesn't close it.
  77. if (!this.isOpen) {
  78. event.stopPropagation()
  79. }
  80. },
  81. timelineName () {
  82. const route = this.$route.name
  83. if (route === 'tag-timeline') {
  84. return '#' + this.$route.params.tag
  85. }
  86. if (route === 'lists-timeline') {
  87. return this.$store.getters.findListTitle(this.$route.params.id)
  88. }
  89. const i18nkey = timelineNames()[this.$route.name]
  90. return i18nkey ? this.$t(i18nkey) : route
  91. }
  92. }
  93. }
  94. export default TimelineMenu