Fix duplicate hosts on render when host_id URL params are present (#3189)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* Fix duplicate hosts on render when host_id URL params are present
|
||||
@@ -56,6 +56,9 @@ const QueryPage = ({
|
||||
setLastEditedQueryObserverCanRun,
|
||||
} = useContext(QueryContext);
|
||||
|
||||
const [queryParamHostsAdded, setQueryParamHostsAdded] = useState<boolean>(
|
||||
false
|
||||
);
|
||||
const [step, setStep] = useState<string>(QUERIES_PAGE_STEPS[1]);
|
||||
const [selectedTargets, setSelectedTargets] = useState<ITarget[]>([]);
|
||||
const [isLiveQueryRunnable, setIsLiveQueryRunnable] = useState<boolean>(true);
|
||||
@@ -94,7 +97,7 @@ const QueryPage = ({
|
||||
"hostFromURL",
|
||||
() => hostAPI.load(parseInt(URLQuerySearch.host_ids as string, 10)),
|
||||
{
|
||||
enabled: !!URLQuerySearch.host_ids,
|
||||
enabled: !!URLQuerySearch.host_ids && !queryParamHostsAdded,
|
||||
select: (data: IHostResponse) => data.host,
|
||||
onSuccess: (data) => {
|
||||
const targets = selectedTargets;
|
||||
@@ -104,6 +107,10 @@ const QueryPage = ({
|
||||
|
||||
targets.push(hostTarget as IHost);
|
||||
setSelectedTargets([...targets]);
|
||||
|
||||
if (!queryParamHostsAdded) {
|
||||
setQueryParamHostsAdded(true);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user