Fix intermitting series state (#115747)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Shahzad 2021-10-29 19:50:14 +02:00 committed by GitHub
parent 9714aac93c
commit d4d470d938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -91,12 +91,12 @@ export const useLensAttributes = (): TypedLensByValueInput['attributes'] | null
const theme = useTheme();
return useMemo(() => {
if (isEmpty(indexPatterns) || isEmpty(allSeries) || !reportType) {
return null;
}
// we only use the data from url to apply, since that get's updated to apply changes
// we only use the data from url to apply, since that gets updated to apply changes
const allSeriesT: AllSeries = convertAllShortSeries(storage.get(allSeriesKey) ?? []);
if (isEmpty(indexPatterns) || isEmpty(allSeriesT) || !reportType) {
return null;
}
const layerConfigs = getLayerConfigs(allSeriesT, reportType, theme, indexPatterns);
if (layerConfigs.length < 1) {
@ -106,5 +106,7 @@ export const useLensAttributes = (): TypedLensByValueInput['attributes'] | null
const lensAttributes = new LensAttributes(layerConfigs);
return lensAttributes.getJSON(lastRefresh);
}, [indexPatterns, allSeries, reportType, storage, theme, lastRefresh]);
// we also want to check the state on allSeries changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [indexPatterns, reportType, storage, theme, lastRefresh, allSeries]);
};

View file

@ -65,7 +65,7 @@ export function LensEmbeddable(props: Props) {
[reportType, setSeries, firstSeries, notifications?.toasts]
);
if (!timeRange || !firstSeries) {
if (!timeRange || !lensAttributes) {
return null;
}