From 3875d26ae8c9be4b5684b7e582eb237113286f99 Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Thu, 19 Dec 2024 14:44:12 +0100 Subject: [PATCH] [Lens][Embeddable] Use reload$ api for custom component (#203755) ## Summary Fixes #203457 Use the `lastReloadRequestTime` prop to trigger a reload in place of the legacy `searchSessionId` system. --- .../renderer/lens_custom_renderer_component.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx index 70d59fc7486b2..3caada55b81db 100644 --- a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx +++ b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx @@ -61,6 +61,7 @@ export function LensRenderer({ disabledActions, searchSessionId, hidePanelTitles, + lastReloadRequestTime, ...props }: LensRendererProps) { // Use the settings interface to store panel settings @@ -86,6 +87,11 @@ export function LensRenderer({ const showPanelChrome = Boolean(withDefaultActions) || (extraActions?.length || 0) > 0; + const reload$ = useMemo(() => new BehaviorSubject(undefined), []); + useEffect(() => { + reload$.next(); + }, [reload$, lastReloadRequestTime]); + // Re-render on changes // internally the embeddable will evaluate whether it is worth to actual render or not useEffect(() => { @@ -152,6 +158,7 @@ export function LensRenderer({ attributes: props.attributes, }), hidePanelTitle: hidePanelTitles$, + reload$, // trigger a reload (replacement for deprepcated searchSessionId) })} onApiAvailable={setLensApi} hidePanelChrome={!showPanelChrome}