Refactor unnecessary store
This commit is contained in:
parent
80e32a7887
commit
92496c8b8e
@ -1,13 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Navbar from "../../Navbar.svelte";
|
import Navbar from "../../Navbar.svelte";
|
||||||
import { unmined } from "../../stores";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ol_proxy,
|
ol_proxy,
|
||||||
|
type Unmined,
|
||||||
type UnminedOptions,
|
type UnminedOptions,
|
||||||
type UnminedRegions,
|
type UnminedRegions,
|
||||||
} from "./unmined";
|
} from "./unmined";
|
||||||
|
|
||||||
|
let unmined: Unmined;
|
||||||
|
|
||||||
export let id = "map";
|
export let id = "map";
|
||||||
|
|
||||||
type Metadata = {
|
type Metadata = {
|
||||||
@ -16,10 +18,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function get_unmined() {
|
async function get_unmined() {
|
||||||
if ($unmined === null) {
|
if (unmined === undefined) {
|
||||||
let resp = await fetch("map/unmined.js");
|
let resp = await fetch("map/unmined.js");
|
||||||
let code = await resp.text();
|
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");
|
let resp = await fetch("map/metadata.js");
|
||||||
@ -29,13 +31,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupMap(node: HTMLDivElement, metadata: Metadata) {
|
function setupMap(node: HTMLDivElement, metadata: Metadata) {
|
||||||
$unmined.map(node.id, metadata.properties, metadata.regions);
|
unmined.map(node.id, metadata.properties, metadata.regions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
destroy() {
|
destroy() {
|
||||||
if ($unmined.openlayersMap) {
|
if (unmined.openlayersMap) {
|
||||||
$unmined.openlayersMap.setTarget(null);
|
unmined.openlayersMap.setTarget(null);
|
||||||
$unmined.openlayersMap = null;
|
unmined.openlayersMap = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
import type { Unmined } from "./pages/mining/unmined";
|
|
||||||
|
|
||||||
type User = {
|
type User = {
|
||||||
name: string,
|
name: string,
|
||||||
@ -7,5 +6,4 @@ type User = {
|
|||||||
picture: string,
|
picture: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const user: Writable<User | null> = writable(null);
|
export const user: Writable<User | null> = writable(null);
|
||||||
export const unmined: Writable<Unmined | null> = writable(null);
|
|
Loading…
Reference in New Issue
Block a user