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

@ -4,14 +4,17 @@ import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson";
import {OsmConnection} from "./Logic/Osm/OsmConnection";
import CustomGeneratorPanel from "./UI/CustomGenerator/CustomGeneratorPanel";
import {LocalStorageSource} from "./Logic/Web/LocalStorageSource";
import {Utils} from "./Utils";
import LZString from "lz-string";
let layout = GenerateEmpty.createEmptyLayout();
if (window.location.hash.length > 10) {
const hash = window.location.hash.substr(1)
try{
layout = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
layout = JSON.parse(atob(hash)) as LayoutConfigJson;
}catch(e){
console.log("Initial load of theme failed, attempt nr 2 with decompression", e)
layout = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
layout = JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(hash)))
}
} else {