Fixed being able to create multiple locs of same name

This commit is contained in:
Donkie
2024-11-20 20:15:46 +01:00
parent 8d6f2636c5
commit 5861190821

View File

@@ -305,6 +305,20 @@ function LocationMetaContainer() {
return <div>Failed to load spools</div>;
}
const addNewLocation = () => {
let newLocationName = "New Location";
const newLocs = [...locationsList];
let i = 1;
while (newLocs.includes(newLocationName)) {
newLocationName = "New Location " + i;
i++;
}
newLocs.push(newLocationName);
setLocationsSetting.mutate(newLocs);
};
return (
<div className="loc-metacontainer">
{containers}
@@ -317,7 +331,7 @@ function LocationMetaContainer() {
style={{
margin: "1em",
}}
onClick={() => setLocationsSetting.mutate([...settingsLocations, "New Location"])}
onClick={addNewLocation}
/>
</div>
</div>