Skip to content

Commit

Permalink
[Lens][Embeddable] Use reload$ api for custom component (elastic#203755)
Browse files Browse the repository at this point in the history
## Summary

Fixes elastic#203457 

Use the `lastReloadRequestTime` prop to trigger a reload in place of the
legacy `searchSessionId` system.
  • Loading branch information
dej611 authored Dec 19, 2024
1 parent 505cc0f commit 3875d26
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function LensRenderer({
disabledActions,
searchSessionId,
hidePanelTitles,
lastReloadRequestTime,
...props
}: LensRendererProps) {
// Use the settings interface to store panel settings
Expand All @@ -86,6 +87,11 @@ export function LensRenderer({

const showPanelChrome = Boolean(withDefaultActions) || (extraActions?.length || 0) > 0;

const reload$ = useMemo(() => new BehaviorSubject<void>(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(() => {
Expand Down Expand Up @@ -152,6 +158,7 @@ export function LensRenderer({
attributes: props.attributes,
}),
hidePanelTitle: hidePanelTitles$,
reload$, // trigger a reload (replacement for deprepcated searchSessionId)
})}
onApiAvailable={setLensApi}
hidePanelChrome={!showPanelChrome}
Expand Down

0 comments on commit 3875d26

Please sign in to comment.