Refactor unnecessary store
This commit is contained in:
parent
80e32a7887
commit
92496c8b8e
@ -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;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
import type { Unmined } from "./pages/mining/unmined";
|
||||
|
||||
type User = {
|
||||
name: string,
|
||||
@ -7,5 +6,4 @@ type User = {
|
||||
picture: string,
|
||||
}
|
||||
|
||||
export const user: Writable<User | null> = writable(null);
|
||||
export const unmined: Writable<Unmined | null> = writable(null);
|
||||
export const user: Writable<User | null> = writable(null);
|
Loading…
Reference in New Issue
Block a user