save generated maplist to localstorage

This commit is contained in:
Kalle (Sendou)
2021-01-12 01:22:28 +02:00
parent 4ef25ccc70
commit 004c468b49

View File

@@ -79,6 +79,12 @@ const MapsGeneratorPage = () => {
);
};
useEffect(() => {
const maplist = localStorage.getItem("maplist");
if (!maplist) return;
setMaplist(maplist);
}, []);
useEffect(() => {
if (!copied) return;
@@ -145,7 +151,7 @@ const MapsGeneratorPage = () => {
const stagesAlreadyPicked = new Set<string>();
const isSZFirst = Math.random() > 0.5;
const isSZFirst = false;
return new Array(count)
.fill(null)
@@ -330,7 +336,11 @@ const MapsGeneratorPage = () => {
<Stack direction={["column", "row"]} spacing={4} mb={4}>
<Button
leftIcon={<FiRotateCw />}
onClick={() => setMaplist(generateMaps())}
onClick={() => {
const maplist = generateMaps();
setMaplist(maplist);
localStorage.setItem("maplist", maplist);
}}
>
<Trans>Generate maps</Trans>
</Button>