Fixed being able to create multiple locs of same name
This commit is contained in:
@@ -305,6 +305,20 @@ function LocationMetaContainer() {
|
|||||||
return <div>Failed to load spools</div>;
|
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 (
|
return (
|
||||||
<div className="loc-metacontainer">
|
<div className="loc-metacontainer">
|
||||||
{containers}
|
{containers}
|
||||||
@@ -317,7 +331,7 @@ function LocationMetaContainer() {
|
|||||||
style={{
|
style={{
|
||||||
margin: "1em",
|
margin: "1em",
|
||||||
}}
|
}}
|
||||||
onClick={() => setLocationsSetting.mutate([...settingsLocations, "New Location"])}
|
onClick={addNewLocation}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user