diff --git a/Logic/Actors/GeoLocationHandler.ts b/Logic/Actors/GeoLocationHandler.ts index ceb363d481..cee9c93006 100644 --- a/Logic/Actors/GeoLocationHandler.ts +++ b/Logic/Actors/GeoLocationHandler.ts @@ -6,6 +6,7 @@ import {LocalStorageSource} from "../Web/LocalStorageSource"; import {VariableUiElement} from "../../UI/Base/VariableUIElement"; import BaseUIElement from "../../UI/BaseUIElement"; import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; +import {QueryParameters} from "../Web/QueryParameters"; export default class GeoLocationHandler extends VariableUiElement { /** @@ -94,8 +95,6 @@ export default class GeoLocationHandler extends VariableUiElement { super( hasLocation.map( (hasLocationData) => { - let icon: BaseUIElement; - console.log("Determining icon:", permission.data, isActive.data, hasLocationData, isLocked.data, lastClickWithinThreeSecs.data) if (permission.data === "denied") { return Svg.location_refused_svg(); } @@ -167,9 +166,12 @@ export default class GeoLocationHandler extends VariableUiElement { } } - self.init(true); + self.init(true, true); }); - this.init(false); + + const latLonGiven = QueryParameters.wasInitialized("lat") && QueryParameters.wasInitialized("lon") + + this.init(false, !latLonGiven); isLocked.addCallbackAndRunD(isLocked => { if (isLocked) { @@ -217,7 +219,7 @@ export default class GeoLocationHandler extends VariableUiElement { }); } - private init(askPermission: boolean) { + private init(askPermission: boolean, forceZoom: boolean) { const self = this; if (self._isActive.data) { @@ -231,7 +233,7 @@ export default class GeoLocationHandler extends VariableUiElement { ?.then(function (status) { console.log("Geolocation is already", status); if (status.state === "granted") { - self.StartGeolocating(false); + self.StartGeolocating(forceZoom); } self._permission.setData(status.state); status.onchange = function () { @@ -243,10 +245,10 @@ export default class GeoLocationHandler extends VariableUiElement { } if (askPermission) { - self.StartGeolocating(true); + self.StartGeolocating(forceZoom); } else if (this._previousLocationGrant.data === "granted") { this._previousLocationGrant.setData(""); - self.StartGeolocating(false); + self.StartGeolocating(forceZoom); } } diff --git a/Logic/Web/QueryParameters.ts b/Logic/Web/QueryParameters.ts index b63ab24c30..5710f373a0 100644 --- a/Logic/Web/QueryParameters.ts +++ b/Logic/Web/QueryParameters.ts @@ -10,6 +10,7 @@ import Combine from "../../UI/Base/Combine"; export class QueryParameters { private static order: string [] = ["layout", "test", "z", "lat", "lon"]; + private static _wasInitialized: Set = new Set() private static knownSources = {}; private static initialized = false; private static defaults = {} @@ -91,6 +92,7 @@ export class QueryParameters { const kv = param.split("="); const key = decodeURIComponent(kv[0]); QueryParameters.addOrder(key) + QueryParameters._wasInitialized.add(key) const v = decodeURIComponent(kv[1]); const source = new UIEventSource(v); source.addCallback(() => QueryParameters.Serialize()) @@ -102,6 +104,10 @@ export class QueryParameters { console.log(QueryParameters.GenerateQueryParameterDocs()) } } + + public static wasInitialized(key: string) : boolean{ + return QueryParameters._wasInitialized.has(key) + } private static Serialize() { const parts = [] diff --git a/Models/Constants.ts b/Models/Constants.ts index 0d0b1af1db..a979b6476b 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -2,7 +2,7 @@ import { Utils } from "../Utils"; export default class Constants { - public static vNumber = "0.9.2"; + public static vNumber = "0.9.3"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = {