Fix user-profile route crash on pinned favorites route
This commit is contained in:
parent
8abaf8fa37
commit
306e254c15
|
@ -80,3 +80,21 @@ export const ROOT_ITEMS = {
|
||||||
criteria: ['announcements']
|
criteria: ['announcements']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function routeTo (item, currentUser) {
|
||||||
|
if (!item.route && !item.routeObject) return null
|
||||||
|
|
||||||
|
let route
|
||||||
|
|
||||||
|
if (item.routeObject) {
|
||||||
|
route = item.routeObject
|
||||||
|
} else {
|
||||||
|
route = { name: (item.anon || currentUser) ? item.route : item.anonRoute }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (USERNAME_ROUTES.has(route.name)) {
|
||||||
|
route.params = { username: currentUser.screen_name, name: currentUser.screen_name }
|
||||||
|
}
|
||||||
|
|
||||||
|
return route
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js'
|
import { routeTo } from 'src/components/navigation/navigation.js'
|
||||||
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
|
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
@ -26,17 +26,7 @@ const NavigationEntry = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
routeTo () {
|
routeTo () {
|
||||||
if (!this.item.route && !this.item.routeObject) return null
|
return routeTo(this.item, this.currentUser)
|
||||||
let route
|
|
||||||
if (this.item.routeObject) {
|
|
||||||
route = this.item.routeObject
|
|
||||||
} else {
|
|
||||||
route = { name: (this.item.anon || this.currentUser) ? this.item.route : this.item.anonRoute }
|
|
||||||
}
|
|
||||||
if (USERNAME_ROUTES.has(route.name)) {
|
|
||||||
route.params = { username: this.currentUser.screen_name, name: this.currentUser.screen_name }
|
|
||||||
}
|
|
||||||
return route
|
|
||||||
},
|
},
|
||||||
getters () {
|
getters () {
|
||||||
return this.$store.getters
|
return this.$store.getters
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { TIMELINES, ROOT_ITEMS, USERNAME_ROUTES } from 'src/components/navigation/navigation.js'
|
import { TIMELINES, ROOT_ITEMS, routeTo } from 'src/components/navigation/navigation.js'
|
||||||
import { getListEntries, filterNavigation } from 'src/components/navigation/filter.js'
|
import { getListEntries, filterNavigation } from 'src/components/navigation/filter.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
@ -31,14 +31,7 @@ const NavPanel = {
|
||||||
props: ['limit'],
|
props: ['limit'],
|
||||||
methods: {
|
methods: {
|
||||||
getRouteTo (item) {
|
getRouteTo (item) {
|
||||||
if (item.routeObject) {
|
return routeTo(item, this.currentUser)
|
||||||
return item.routeObject
|
|
||||||
}
|
|
||||||
const route = { name: (item.anon || this.currentUser) ? item.route : item.anonRoute }
|
|
||||||
if (USERNAME_ROUTES.has(route.name)) {
|
|
||||||
route.params = { username: this.currentUser.screen_name }
|
|
||||||
}
|
|
||||||
return route
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
Loading…
Reference in New Issue