Fix another localStorage bug

This commit is contained in:
Neshura 2024-05-20 02:19:19 +02:00
parent 5d8375a9c8
commit 1398154b4b
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
5 changed files with 34 additions and 137 deletions

1
src/routes/+layout.ts Normal file
View file

@ -0,0 +1 @@
export const prerender = true;

View file

@ -158,41 +158,33 @@
if (navigator) {
locale = navigator.language;
}
let localThrusters = localStorage.getItem("thrusters");
if (typeof localThrusters !== "undefined" && localThrusters !== "" && localGravity != null) {
thrusters = JSON.parse(localThrusters);
if (localStorage.getItem("thrusters") !== null) {
thrusters = JSON.parse(localStorage.getItem("thrusters"))
}
let localInventories = localStorage.getItem("inventories");
if (typeof localInventories !== "undefined" && localInventories !== "" && localGravity != null) {
inventories = JSON.parse(localInventories);
if (localStorage.getItem("inventories") !== null) {
inventories = JSON.parse(localStorage.getItem("inventories"))
}
let localGridSize = localStorage.getItem("gridSize");
if (typeof localGridSize !== "undefined" && localGridSize !== "" && localGravity != null) {
gridSize = localGridSize;
if (localStorage.getItem("gridSize") !== null) {
gridSize = localStorage.getItem("gridSize")
}
console.log(gravity);
let localGravity = localStorage.getItem("gravity");
if (typeof localGravity !== "undefined" && localGravity !== "" && localGravity != null) {
console.log(localGravity);
gravity = localGravity;
if (localStorage.getItem("gravity") !== null) {
gravity = localStorage.getItem("gravity")
}
let localInventoryMultiplicator = localStorage.getItem("inventoryMultiplier");
if (typeof localInventoryMultiplicator !== "undefined" && localInventoryMultiplicator !== "" && localGravity != null) {
inventoryMultiplier = localInventoryMultiplicator;
if (localStorage.getItem("inventoryMultiplier") !== null) {
inventoryMultiplier = localStorage.getItem("inventoryMultiplier")
}
let localNewThruster = localStorage.getItem("newThruster");
if (typeof localNewThruster !== "undefined" && localNewThruster !== "" && localGravity != null) {
newThruster = JSON.parse(localNewThruster);
if (localStorage.getItem("newThruster") !== null) {
newThruster = JSON.parse(localStorage.getItem("newThruster"))
}
let localNewInventory = localStorage.getItem("newInventory");
if (typeof localNewInventory !== "undefined" && localNewInventory !== "" && localGravity != null) {
newInventory = JSON.parse(localNewInventory);
if (localStorage.getItem("newInventory") !== null) {
newInventory = JSON.parse(localStorage.getItem("newInventory"))
}
mounted = true;