fix(dashboard): avoid undefined error when dashboard is not ready yet

pull/5521/head
Pavel Zavora 2020-06-21 10:22:14 +02:00
parent 71b9d07f4f
commit 9639fc469b
1 changed files with 4 additions and 4 deletions

View File

@ -27,6 +27,10 @@ export const updateDashboardLinks = (
) => {
const {active} = dashboardLinks
if (!activeDashboard) {
return {...dashboardLinks, active: null}
}
if (!active || active.key !== String(activeDashboard.id)) {
return updateActiveDashboardLink(dashboardLinks, activeDashboard)
}
@ -38,10 +42,6 @@ const updateActiveDashboardLink = (
dashboardLinks: DashboardSwitcherLinks,
dashboard: Dashboard
) => {
if (!dashboard) {
return {...dashboardLinks, active: null}
}
const active = dashboardLinks.links.find(
link => link.key === String(dashboard.id)
)