From a6da3da6dc5eb3b712d1d94c1d1d9239b5761414 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Tue, 22 Oct 2024 19:18:20 +0200 Subject: [PATCH] Follow up review --- .../no_data/dashboard_app_no_data.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx b/src/plugins/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx index 25d2bf33f32a8..366726267c311 100644 --- a/src/plugins/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx +++ b/src/plugins/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx @@ -10,7 +10,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; import useAsync from 'react-use/lib/useAsync'; -import useMountedState from 'react-use/lib/useMountedState'; import { v4 as uuidv4 } from 'uuid'; import { getESQLAdHocDataview, @@ -52,7 +51,6 @@ export const DashboardAppNoDataPage = ({ share: shareService, }; const [abortController, setAbortController] = useState(new AbortController()); - const isMounted = useMountedState(); const importPromise = import('@kbn/shared-ux-page-analytics-no-data'); const AnalyticsNoDataPageKibanaProvider = withSuspense( React.lazy(() => @@ -74,7 +72,7 @@ export const DashboardAppNoDataPage = ({ const onTryESQL = useCallback(async () => { abortController?.abort(); - if (lensHelpersAsync.value && isMounted()) { + if (lensHelpersAsync.value) { const abc = new AbortController(); const { dataViews } = dataService; const indexName = (await getIndexForESQLQuery({ dataViews })) ?? '*'; @@ -126,15 +124,17 @@ export const DashboardAppNoDataPage = ({ }); } } catch (error) { - coreServices.notifications.toasts.addWarning( - i18n.translate('dashboard.noDataviews.esqlRequestWarningMessage', { - defaultMessage: 'Unable to load columns. {errorMessage}', - values: { errorMessage: error.message }, - }) - ); + if (error.name !== 'AbortError') { + coreServices.notifications.toasts.addWarning( + i18n.translate('dashboard.noDataviews.esqlRequestWarningMessage', { + defaultMessage: 'Unable to load columns. {errorMessage}', + values: { errorMessage: error.message }, + }) + ); + } } } - }, [abortController, isMounted, lensHelpersAsync.value]); + }, [abortController, lensHelpersAsync.value]); const AnalyticsNoDataPage = withSuspense( React.lazy(() =>