Fix loading of compressed themes in the custom generator too

This commit is contained in:
Pieter Vander Vennet 2021-04-11 23:43:23 +02:00
parent d601896f79
commit 9874b7d8c8
3 changed files with 16 additions and 6 deletions

View file

@ -1,6 +1,8 @@
import {UIEventSource} from "../UIEventSource";
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
import {OsmConnection} from "../Osm/OsmConnection";
import {Utils} from "../../Utils";
import LZString from "lz-string";
export default class InstalledThemes {
public installedThemes: UIEventSource<{ layout: LayoutConfig; definition: string }[]>;
@ -22,9 +24,13 @@ export default class InstalledThemes {
continue;
}
try {
const json = atob(customLayout.data);
const layout = new LayoutConfig(
JSON.parse(json), false);
let layoutJson;
try{
layoutJson = JSON.parse(atob(customLayout.data))
}catch(e){
layoutJson = JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(customLayout.data)))
}
const layout = new LayoutConfig(layoutJson, false);
installedThemes.push({
layout: layout,
definition: customLayout.data