♻️ refactor

This commit is contained in:
Fred KISSIE
2026-03-20 04:02:51 +01:00
parent ce58e71c44
commit 02697e27a4
4 changed files with 15 additions and 13 deletions

View File

@@ -41,21 +41,21 @@ export function MachineSelector({
orgQueries.machineClients({ orgId, perPage: 10, query: debouncedValue })
);
// always include the selected site in the list of sites shown
// always include the selected machines in the list of machines shown (if the user isn't searching)
const machinesShown = useMemo(() => {
const allMachines: Array<SelectedMachine> = [...machines];
for (const machine of selectedMachines) {
if (
!allMachines.find(
(machine) => machine.clientId === machine.clientId
)
) {
allMachines.unshift(machine);
if (debouncedValue.trim().length === 0) {
for (const machine of selectedMachines) {
if (
!allMachines.find((mc) => mc.clientId === machine.clientId)
) {
allMachines.unshift(machine);
}
}
}
return allMachines;
}, [machines, selectedMachines]);
}, [machines, selectedMachines, debouncedValue]);
const selectedMachinesIds = new Set(
selectedMachines.map((m) => m.clientId)