forked from MapComplete/MapComplete
Fix loading of the hash of a custom theme, even if the custom theme is not loaded via the URL. Fixes 352
This commit is contained in:
parent
9a73ae4c47
commit
6c3b8b2020
2 changed files with 5 additions and 7 deletions
|
@ -215,7 +215,7 @@ export class InitUiElements {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static LoadLayoutFromHash(userLayoutParam: UIEventSource<string>) {
|
static LoadLayoutFromHash(userLayoutParam: UIEventSource<string>): [LayoutConfig, string]{
|
||||||
try {
|
try {
|
||||||
let hash = location.hash.substr(1);
|
let hash = location.hash.substr(1);
|
||||||
const layoutFromBase64 = userLayoutParam.data;
|
const layoutFromBase64 = userLayoutParam.data;
|
||||||
|
@ -247,7 +247,7 @@ export class InitUiElements {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const layoutToUse = new LayoutConfig(json, false);
|
const layoutToUse = new LayoutConfig(json, false);
|
||||||
userLayoutParam.setData(layoutToUse.id);
|
userLayoutParam.setData(layoutToUse.id);
|
||||||
return layoutToUse;
|
return [layoutToUse, btoa(Utils.MinifyJSON(JSON.stringify(json)))];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
new FixedUiElement("Error: could not parse the custom layout:<br/> " + e).AttachTo("centermessage");
|
new FixedUiElement("Error: could not parse the custom layout:<br/> " + e).AttachTo("centermessage");
|
||||||
|
|
8
index.ts
8
index.ts
|
@ -5,7 +5,6 @@ import {QueryParameters} from "./Logic/Web/QueryParameters";
|
||||||
import {UIEventSource} from "./Logic/UIEventSource";
|
import {UIEventSource} from "./Logic/UIEventSource";
|
||||||
import * as $ from "jquery";
|
import * as $ from "jquery";
|
||||||
import LayoutConfig from "./Customizations/JSON/LayoutConfig";
|
import LayoutConfig from "./Customizations/JSON/LayoutConfig";
|
||||||
import {Utils} from "./Utils";
|
|
||||||
import MoreScreen from "./UI/BigComponents/MoreScreen";
|
import MoreScreen from "./UI/BigComponents/MoreScreen";
|
||||||
import State from "./State";
|
import State from "./State";
|
||||||
import Combine from "./UI/Base/Combine";
|
import Combine from "./UI/Base/Combine";
|
||||||
|
@ -34,7 +33,6 @@ if (location.href.indexOf("buurtnatuur.be") >= 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let testing: UIEventSource<string>;
|
let testing: UIEventSource<string>;
|
||||||
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
||||||
testing = QueryParameters.GetQueryParameter("test", "true");
|
testing = QueryParameters.GetQueryParameter("test", "true");
|
||||||
|
@ -88,7 +86,7 @@ new Combine(["Initializing... <br/>",
|
||||||
new FixedUiElement("<a>If this message persist, something went wrong - click here to try again</a>")
|
new FixedUiElement("<a>If this message persist, something went wrong - click here to try again</a>")
|
||||||
.SetClass("link-underline small")
|
.SetClass("link-underline small")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
|
|
||||||
})])
|
})])
|
||||||
|
@ -136,8 +134,8 @@ if (layoutFromBase64.startsWith("http")) {
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (layoutFromBase64 !== "false") {
|
} else if (layoutFromBase64 !== "false") {
|
||||||
layoutToUse = InitUiElements.LoadLayoutFromHash(userLayoutParam);
|
let [layoutToUse, encoded] = InitUiElements.LoadLayoutFromHash(userLayoutParam);
|
||||||
InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout, location.hash.substr(1));
|
InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout, encoded);
|
||||||
} else if (layoutToUse !== undefined) {
|
} else if (layoutToUse !== undefined) {
|
||||||
// This is the default case: a builtin theme
|
// This is the default case: a builtin theme
|
||||||
InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout);
|
InitUiElements.InitAll(layoutToUse, layoutFromBase64, testing, defaultLayout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue