From 9639fc469b2054670e0b0d03a352bd6212780a39 Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Sun, 21 Jun 2020 10:22:14 +0200 Subject: [PATCH] fix(dashboard): avoid undefined error when dashboard is not ready yet --- ui/src/dashboards/utils/dashboardSwitcherLinks.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/dashboards/utils/dashboardSwitcherLinks.ts b/ui/src/dashboards/utils/dashboardSwitcherLinks.ts index 07f0afcef..7d6cf6f92 100644 --- a/ui/src/dashboards/utils/dashboardSwitcherLinks.ts +++ b/ui/src/dashboards/utils/dashboardSwitcherLinks.ts @@ -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) )