mirror of
https://github.com/upscayl/upscayl.git
synced 2026-04-03 03:00:13 -04:00
Replace filter with map
This commit is contained in:
@@ -267,12 +267,11 @@ const Home = () => {
|
||||
};
|
||||
});
|
||||
// Add newModelsList to modelOptions and remove duplicates
|
||||
const combinedModelOptions = [...modelOptions, ...newModelOptions];
|
||||
const uniqueModelOptions = combinedModelOptions.filter(
|
||||
// Check if any model in the array appears more than once
|
||||
(model, index, array) =>
|
||||
array.findIndex((t) => t.value === model.value) === index,
|
||||
);
|
||||
const modelMap = new Map();
|
||||
[...modelOptions, ...newModelOptions].forEach((model) => {
|
||||
modelMap.set(model.value, model);
|
||||
});
|
||||
const uniqueModelOptions = Array.from(modelMap.values());
|
||||
setModelOptions(uniqueModelOptions);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user