Refactor unnecessary store

This commit is contained in:
Kai Vogelgesang 2022-09-12 01:19:51 +02:00
parent 80e32a7887
commit 92496c8b8e
Signed by: kai
GPG Key ID: 0A95D3B6E62C0879
2 changed files with 10 additions and 10 deletions

View File

@ -1,13 +1,15 @@
<script lang="ts">
import Navbar from "../../Navbar.svelte";
import { unmined } from "../../stores";
import {
ol_proxy,
type Unmined,
type UnminedOptions,
type UnminedRegions,
} from "./unmined";
let unmined: Unmined;
export let id = "map";
type Metadata = {
@ -16,10 +18,10 @@
};
async function get_unmined() {
if ($unmined === null) {
if (unmined === undefined) {
let resp = await fetch("map/unmined.js");
let code = await resp.text();
$unmined = Function("ol", code).call({}, ol_proxy);
unmined = Function("ol", code).call({}, ol_proxy);
}
let resp = await fetch("map/metadata.js");
@ -29,13 +31,13 @@
}
function setupMap(node: HTMLDivElement, metadata: Metadata) {
$unmined.map(node.id, metadata.properties, metadata.regions);
unmined.map(node.id, metadata.properties, metadata.regions);
return {
destroy() {
if ($unmined.openlayersMap) {
$unmined.openlayersMap.setTarget(null);
$unmined.openlayersMap = null;
if (unmined.openlayersMap) {
unmined.openlayersMap.setTarget(null);
unmined.openlayersMap = null;
}
},
};

View File

@ -1,5 +1,4 @@
import { writable, type Writable } from "svelte/store";
import type { Unmined } from "./pages/mining/unmined";
type User = {
name: string,
@ -8,4 +7,3 @@ type User = {
}
export const user: Writable<User | null> = writable(null);
export const unmined: Writable<Unmined | null> = writable(null);