mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fix duplicate hosts on render when host_id URL params are present (#3189)
This commit is contained in:
parent
6ee6dba4a4
commit
b3a69680e7
2 changed files with 9 additions and 1 deletions
1
changes/issue-3064-duplicate-hosts
Normal file
1
changes/issue-3064-duplicate-hosts
Normal file
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue