Fix loading of themes in the custom generator: use compression
This commit is contained in:
parent
63187aab04
commit
d601896f79
2 changed files with 11 additions and 7 deletions
|
@ -39,6 +39,8 @@ import SelectedFeatureHandler from "./Logic/Actors/SelectedFeatureHandler";
|
||||||
import LZString from "lz-string";
|
import LZString from "lz-string";
|
||||||
import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson";
|
import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson";
|
||||||
import AttributionPanel from "./UI/BigComponents/AttributionPanel";
|
import AttributionPanel from "./UI/BigComponents/AttributionPanel";
|
||||||
|
import AllKnownLayers from "./Customizations/AllKnownLayers";
|
||||||
|
import LayerConfig from "./Customizations/JSON/LayerConfig";
|
||||||
|
|
||||||
export class InitUiElements {
|
export class InitUiElements {
|
||||||
|
|
||||||
|
@ -83,13 +85,9 @@ export class InitUiElements {
|
||||||
// This is purely for the personal theme to load the layers there
|
// This is purely for the personal theme to load the layers there
|
||||||
const favs = State.state.favouriteLayers.data ?? [];
|
const favs = State.state.favouriteLayers.data ?? [];
|
||||||
|
|
||||||
|
|
||||||
layoutToUse.layers.splice(0, layoutToUse.layers.length);
|
layoutToUse.layers.splice(0, layoutToUse.layers.length);
|
||||||
for (const fav of favs) {
|
for (const fav of favs) {
|
||||||
const layer = AllKnownLayouts.allLayers[fav];
|
|
||||||
if (!!layer) {
|
|
||||||
layoutToUse.layers.push(layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const layouts of State.state.installedThemes.data) {
|
for (const layouts of State.state.installedThemes.data) {
|
||||||
for (const layer of layouts.layout.layers) {
|
for (const layer of layouts.layout.layers) {
|
||||||
if (typeof layer === "string") {
|
if (typeof layer === "string") {
|
||||||
|
@ -218,7 +216,7 @@ 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( Utils.UnMinify(LZString.decompressFromBase64(hash)))
|
json = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
@ -7,7 +7,13 @@ import {LocalStorageSource} from "./Logic/Web/LocalStorageSource";
|
||||||
|
|
||||||
let layout = GenerateEmpty.createEmptyLayout();
|
let layout = GenerateEmpty.createEmptyLayout();
|
||||||
if (window.location.hash.length > 10) {
|
if (window.location.hash.length > 10) {
|
||||||
layout = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
|
try{
|
||||||
|
layout = JSON.parse(atob(window.location.hash.substr(1))) 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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const hash = LocalStorageSource.Get("last-custom-theme").data
|
const hash = LocalStorageSource.Get("last-custom-theme").data
|
||||||
if (hash !== undefined) {
|
if (hash !== undefined) {
|
||||||
|
|
Loading…
Reference in a new issue