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 (2881B)


  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. }
  22. }
  23. const TimelineMenu = {
  24. components: {
  25. Popover,
  26. NavigationEntry,
  27. ListsMenuContent
  28. },
  29. data () {
  30. return {
  31. isOpen: false
  32. }
  33. },
  34. created () {
  35. if (timelineNames()[this.$route.name]) {
  36. this.$store.dispatch('setLastTimeline', this.$route.name)
  37. }
  38. },
  39. computed: {
  40. useListsMenu () {
  41. const route = this.$route.name
  42. return route === 'lists-timeline'
  43. },
  44. ...mapState({
  45. currentUser: state => state.users.currentUser,
  46. privateMode: state => state.instance.private,
  47. federating: state => state.instance.federating
  48. }),
  49. timelinesList () {
  50. return filterNavigation(
  51. Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
  52. {
  53. hasChats: this.pleromaChatMessagesAvailable,
  54. isFederating: this.federating,
  55. isPrivate: this.privateMode,
  56. currentUser: this.currentUser
  57. }
  58. )
  59. }
  60. },
  61. methods: {
  62. openMenu () {
  63. // $nextTick is too fast, animation won't play back but
  64. // instead starts in fully open position. Low values
  65. // like 1-5 work on fast machines but not on mobile, 25
  66. // seems like a good compromise that plays without significant
  67. // added lag.
  68. setTimeout(() => {
  69. this.isOpen = true
  70. }, 25)
  71. },
  72. blockOpen (event) {
  73. // For the blank area inside the button element.
  74. // Just setting @click.stop="" makes unintuitive behavior when
  75. // menu is open and clicking on the blank area doesn't close it.
  76. if (!this.isOpen) {
  77. event.stopPropagation()
  78. }
  79. },
  80. timelineName () {
  81. const route = this.$route.name
  82. if (route === 'tag-timeline') {
  83. return '#' + this.$route.params.tag
  84. }
  85. if (route === 'lists-timeline') {
  86. return this.$store.getters.findListTitle(this.$route.params.id)
  87. }
  88. const i18nkey = timelineNames()[this.$route.name]
  89. return i18nkey ? this.$t(i18nkey) : route
  90. }
  91. }
  92. }
  93. export default TimelineMenu