forked from MapComplete/MapComplete
Cleanup imports, improve typing
This commit is contained in:
parent
d4085d608b
commit
3204a76fc9
2 changed files with 4 additions and 7 deletions
|
@ -4,7 +4,6 @@
|
||||||
import type { Feature } from "geojson"
|
import type { Feature } from "geojson"
|
||||||
import type { SpecialVisualizationState } from "../../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../../SpecialVisualization"
|
||||||
import TagRenderingAnswer from "./TagRenderingAnswer.svelte"
|
import TagRenderingAnswer from "./TagRenderingAnswer.svelte"
|
||||||
import { PencilAltIcon } from "@rgossiaux/svelte-heroicons/solid"
|
|
||||||
import TagRenderingQuestion from "./TagRenderingQuestion.svelte"
|
import TagRenderingQuestion from "./TagRenderingQuestion.svelte"
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
import Tr from "../../Base/Tr.svelte"
|
import Tr from "../../Base/Tr.svelte"
|
||||||
|
@ -12,9 +11,7 @@
|
||||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||||
import { Utils } from "../../../Utils"
|
import { Utils } from "../../../Utils"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
import { ariaLabel } from "../../../Utils/ariaLabel"
|
|
||||||
import EditButton from "./EditButton.svelte"
|
import EditButton from "./EditButton.svelte"
|
||||||
import EditItemButton from "../../Studio/EditItemButton.svelte"
|
|
||||||
|
|
||||||
export let config: TagRenderingConfig
|
export let config: TagRenderingConfig
|
||||||
export let tags: UIEventSource<Record<string, string>>
|
export let tags: UIEventSource<Record<string, string>>
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const promise =
|
const promise =
|
||||||
/*NO AWAIT as we work with the promise directly */ Utils.downloadJsonAdvanced(
|
/*NO AWAIT as we work with the promise directly */ Utils.downloadJsonAdvanced<T>(
|
||||||
url,
|
url,
|
||||||
headers
|
headers
|
||||||
)
|
)
|
||||||
|
@ -1069,11 +1069,11 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async downloadJsonAdvanced(
|
public static async downloadJsonAdvanced<T = object | []>(
|
||||||
url: string,
|
url: string,
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
): Promise<
|
): Promise<
|
||||||
{ content: object | object[] } | { error: string; url: string; statuscode?: number }
|
{ content: T } | { error: string; url: string; statuscode?: number }
|
||||||
> {
|
> {
|
||||||
const injected = Utils.injectedDownloads[url]
|
const injected = Utils.injectedDownloads[url]
|
||||||
if (injected !== undefined) {
|
if (injected !== undefined) {
|
||||||
|
@ -1091,7 +1091,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
||||||
try {
|
try {
|
||||||
if (typeof data === "string") {
|
if (typeof data === "string") {
|
||||||
if (data === "") {
|
if (data === "") {
|
||||||
return { content: {} }
|
return { content: <T> {} }
|
||||||
}
|
}
|
||||||
return { content: JSON.parse(data) }
|
return { content: JSON.parse(data) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue