2020-07-02 15:03:02 +00:00
|
|
|
import Popover from '../popover/popover.vue'
|
2021-02-22 14:24:04 +00:00
|
|
|
import TimelineMenuContent from './timeline_menu_content.vue'
|
2020-10-19 16:38:49 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faChevronDown
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
2021-02-22 14:24:04 +00:00
|
|
|
library.add(faChevronDown)
|
2020-07-02 15:03:02 +00:00
|
|
|
|
2020-11-10 10:52:54 +00:00
|
|
|
// Route -> i18n key mapping, exported and not in the computed
|
2020-07-07 14:34:35 +00:00
|
|
|
// because nav panel benefits from the same information.
|
|
|
|
export const timelineNames = () => {
|
|
|
|
return {
|
2021-02-22 14:24:04 +00:00
|
|
|
'friends': 'nav.home_timeline',
|
2020-07-07 14:34:35 +00:00
|
|
|
'bookmarks': 'nav.bookmarks',
|
|
|
|
'dms': 'nav.dms',
|
|
|
|
'public-timeline': 'nav.public_tl',
|
2022-07-22 14:36:45 +00:00
|
|
|
'public-external-timeline': 'nav.twkn',
|
|
|
|
'bubble-timeline': 'nav.bubble_timeline'
|
2020-07-07 14:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-02 15:03:02 +00:00
|
|
|
const TimelineMenu = {
|
|
|
|
components: {
|
2021-02-22 14:24:04 +00:00
|
|
|
Popover,
|
|
|
|
TimelineMenuContent
|
2020-07-02 15:03:02 +00:00
|
|
|
},
|
2020-07-03 09:56:31 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2022-06-18 13:04:18 +00:00
|
|
|
isOpen: false
|
2020-07-03 09:56:31 +00:00
|
|
|
}
|
|
|
|
},
|
2020-07-02 15:03:02 +00:00
|
|
|
created () {
|
2020-07-28 06:41:00 +00:00
|
|
|
if (timelineNames()[this.$route.name]) {
|
2020-07-28 06:40:04 +00:00
|
|
|
this.$store.dispatch('setLastTimeline', this.$route.name)
|
|
|
|
}
|
2020-07-02 15:03:02 +00:00
|
|
|
},
|
2020-07-03 09:56:31 +00:00
|
|
|
methods: {
|
|
|
|
openMenu () {
|
2020-07-07 14:34:35 +00:00
|
|
|
// $nextTick is too fast, animation won't play back but
|
|
|
|
// instead starts in fully open position. Low values
|
|
|
|
// like 1-5 work on fast machines but not on mobile, 25
|
|
|
|
// seems like a good compromise that plays without significant
|
|
|
|
// added lag.
|
2020-07-03 09:56:31 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.isOpen = true
|
2020-07-07 14:34:35 +00:00
|
|
|
}, 25)
|
2020-08-19 10:06:46 +00:00
|
|
|
},
|
2020-12-03 08:07:42 +00:00
|
|
|
blockOpen (event) {
|
|
|
|
// For the blank area inside the button element.
|
|
|
|
// Just setting @click.stop="" makes unintuitive behavior when
|
|
|
|
// menu is open and clicking on the blank area doesn't close it.
|
|
|
|
if (!this.isOpen) {
|
|
|
|
event.stopPropagation()
|
|
|
|
}
|
|
|
|
},
|
2020-08-19 10:06:46 +00:00
|
|
|
timelineName () {
|
|
|
|
const route = this.$route.name
|
|
|
|
if (route === 'tag-timeline') {
|
|
|
|
return '#' + this.$route.params.tag
|
|
|
|
}
|
2022-06-16 07:42:45 +00:00
|
|
|
if (route === 'list-timeline') {
|
2022-06-18 13:04:18 +00:00
|
|
|
return this.$store.getters.findListTitle(this.$route.params.id)
|
2022-06-16 07:42:45 +00:00
|
|
|
}
|
2020-08-19 10:06:46 +00:00
|
|
|
const i18nkey = timelineNames()[this.$route.name]
|
|
|
|
return i18nkey ? this.$t(i18nkey) : route
|
2020-07-03 09:56:31 +00:00
|
|
|
}
|
2020-07-02 15:03:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TimelineMenu
|