forked from MapComplete/MapComplete
Performance: drop "known_themes"-file
This commit is contained in:
parent
b913ea867f
commit
310b973846
4 changed files with 15 additions and 25 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import known_themes from "../assets/generated/known_themes.json"
|
||||
import ThemeConfig from "../Models/ThemeConfig/ThemeConfig"
|
||||
import favourite from "../assets/generated/layers/favourite.json"
|
||||
import { ThemeConfigJson } from "../Models/ThemeConfig/Json/ThemeConfigJson"
|
||||
import { AllSharedLayers } from "./AllSharedLayers"
|
||||
import Constants from "../Models/Constants"
|
||||
import ScriptUtils from "../../scripts/ScriptUtils"
|
||||
import { readFileSync } from "fs"
|
||||
|
||||
/**
|
||||
* Somewhat of a dictionary, which lazily parses needed themes
|
||||
|
|
@ -13,11 +14,14 @@ export class AllKnownLayoutsLazy {
|
|||
private readonly dict: Map<string, ThemeConfig> = new Map()
|
||||
|
||||
constructor(includeFavouriteLayer = true) {
|
||||
for (const layoutConfigJson of known_themes["themes"]) {
|
||||
const paths = ScriptUtils.readDirRecSync("./src/assets/generated/themes/",1)
|
||||
|
||||
for (const path of paths) {
|
||||
const themeConfigJson = <ThemeConfigJson> JSON.parse(readFileSync(path, "utf8"))
|
||||
for (const layerId of Constants.added_by_default) {
|
||||
if (layerId === "favourite" && favourite.id) {
|
||||
if (includeFavouriteLayer) {
|
||||
layoutConfigJson.layers.push(favourite)
|
||||
themeConfigJson.layers.push(favourite)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
@ -26,9 +30,9 @@ export class AllKnownLayoutsLazy {
|
|||
console.error("Could not find builtin layer", layerId)
|
||||
continue
|
||||
}
|
||||
layoutConfigJson.layers.push(defaultLayer)
|
||||
themeConfigJson.layers.push(defaultLayer)
|
||||
}
|
||||
this.raw.set(layoutConfigJson.id, layoutConfigJson)
|
||||
this.raw.set(themeConfigJson.id, themeConfigJson)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue