Fix loading of compressed themes in the custom generator too
This commit is contained in:
parent
d601896f79
commit
9874b7d8c8
3 changed files with 16 additions and 6 deletions
|
@ -216,7 +216,8 @@ export class InitUiElements {
|
||||||
json = JSON.parse(atob(hash));
|
json = JSON.parse(atob(hash));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// We try to decode with lz-string
|
// We try to decode with lz-string
|
||||||
json = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
|
json = JSON.parse( Utils.UnMinify(LZString.decompressFromBase64(hash))) as LayoutConfigJson;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import {UIEventSource} from "../UIEventSource";
|
import {UIEventSource} from "../UIEventSource";
|
||||||
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
||||||
import {OsmConnection} from "../Osm/OsmConnection";
|
import {OsmConnection} from "../Osm/OsmConnection";
|
||||||
|
import {Utils} from "../../Utils";
|
||||||
|
import LZString from "lz-string";
|
||||||
|
|
||||||
export default class InstalledThemes {
|
export default class InstalledThemes {
|
||||||
public installedThemes: UIEventSource<{ layout: LayoutConfig; definition: string }[]>;
|
public installedThemes: UIEventSource<{ layout: LayoutConfig; definition: string }[]>;
|
||||||
|
@ -22,9 +24,13 @@ export default class InstalledThemes {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const json = atob(customLayout.data);
|
let layoutJson;
|
||||||
const layout = new LayoutConfig(
|
try{
|
||||||
JSON.parse(json), false);
|
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({
|
installedThemes.push({
|
||||||
layout: layout,
|
layout: layout,
|
||||||
definition: customLayout.data
|
definition: customLayout.data
|
||||||
|
|
|
@ -4,14 +4,17 @@ import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson";
|
||||||
import {OsmConnection} from "./Logic/Osm/OsmConnection";
|
import {OsmConnection} from "./Logic/Osm/OsmConnection";
|
||||||
import CustomGeneratorPanel from "./UI/CustomGenerator/CustomGeneratorPanel";
|
import CustomGeneratorPanel from "./UI/CustomGenerator/CustomGeneratorPanel";
|
||||||
import {LocalStorageSource} from "./Logic/Web/LocalStorageSource";
|
import {LocalStorageSource} from "./Logic/Web/LocalStorageSource";
|
||||||
|
import {Utils} from "./Utils";
|
||||||
|
import LZString from "lz-string";
|
||||||
|
|
||||||
let layout = GenerateEmpty.createEmptyLayout();
|
let layout = GenerateEmpty.createEmptyLayout();
|
||||||
if (window.location.hash.length > 10) {
|
if (window.location.hash.length > 10) {
|
||||||
|
const hash = window.location.hash.substr(1)
|
||||||
try{
|
try{
|
||||||
layout = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
|
layout = JSON.parse(atob(hash)) as LayoutConfigJson;
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log("Initial load of theme failed, attempt nr 2 with decompression", 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 {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue