mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] AIOps: Fixes timefilter subscriptions. (#149576)
The `useEffect` hooks that set up subscriptions related to the `timefilter` were missing `[]` to be only called when the code is mounted, without it they were called on every render. This PR adds the missing `[]` and also combines the two hooks into one.
This commit is contained in:
parent
db7bc1423b
commit
b87d754e9e
1 changed files with 8 additions and 10 deletions
|
@ -148,7 +148,7 @@ export const useData = (
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
const timeUpdateSubscription = merge(
|
||||
const timefilterUpdateSubscription = merge(
|
||||
timefilter.getAutoRefreshFetch$(),
|
||||
timefilter.getTimeUpdate$(),
|
||||
mlTimefilterRefresh$
|
||||
|
@ -161,22 +161,20 @@ export const useData = (
|
|||
}
|
||||
updateFieldStatsRequest();
|
||||
});
|
||||
return () => {
|
||||
timeUpdateSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
|
||||
// This hook listens just for an initial update of the timefilter to be switched on.
|
||||
useEffect(() => {
|
||||
const timeUpdateSubscription = timefilter.getEnabledUpdated$().subscribe(() => {
|
||||
// This listens just for an initial update of the timefilter to be switched on.
|
||||
const timefilterEnabledSubscription = timefilter.getEnabledUpdated$().subscribe(() => {
|
||||
if (fieldStatsRequest === undefined) {
|
||||
updateFieldStatsRequest();
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
timeUpdateSubscription.unsubscribe();
|
||||
timefilterUpdateSubscription.unsubscribe();
|
||||
timefilterEnabledSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Ensure request is updated when search changes
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue