Fix navigator undefined error

This commit is contained in:
Neshura 2024-05-20 01:21:35 +02:00
parent 872f1b38ae
commit 154c50c67b
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -17,7 +17,7 @@
import {Separator} from "$lib/components/ui/separator"; import {Separator} from "$lib/components/ui/separator";
import {onMount} from "svelte"; import {onMount} from "svelte";
let locale = $state(navigator.language); let locale = $state("en-GB");
let mounted = $state(false); let mounted = $state(false);
let thrusters: Array<Thruster> = $state([]) let thrusters: Array<Thruster> = $state([])
@ -155,6 +155,9 @@
} }
onMount(() => { onMount(() => {
if (navigator) {
locale = navigator.language;
}
let localThrusters = localStorage.getItem("thrusters"); let localThrusters = localStorage.getItem("thrusters");
if (typeof localThrusters !== "undefined" && localThrusters !== "") { if (typeof localThrusters !== "undefined" && localThrusters !== "") {
thrusters = JSON.parse(localThrusters); thrusters = JSON.parse(localThrusters);