diff --git a/src/Logic/Osm/OsmConnection.ts b/src/Logic/Osm/OsmConnection.ts index 4bad04ff4..2295c578e 100644 --- a/src/Logic/Osm/OsmConnection.ts +++ b/src/Logic/Osm/OsmConnection.ts @@ -135,7 +135,7 @@ export class OsmConnection { oauth_token?: UIEventSource // Used to keep multiple changesets open and to write to the correct changeset singlePage?: boolean - attemptLogin?: true | boolean + attemptLogin?: boolean /** * If true: automatically check if we're still online every 5 minutes + fetch messages */ @@ -183,9 +183,9 @@ export class OsmConnection { this._dryRun = options.dryRun ?? new UIEventSource(false) - this.createAuthObject() + this.updateAuthObject(false) AndroidPolyfill.inAndroid.addCallback(() => { - this.createAuthObject() + this.updateAuthObject(false) }) if (!this.fakeUser) { this.CheckForMessagesContinuously() @@ -261,8 +261,7 @@ export class OsmConnection { console.log("AttemptLogin called, but ignored as fakeUser is set") return } - - console.log("Trying to log in...") + this.updateAuthObject(true) LocalStorageSource.get("location_before_login").setData( Utils.runningFromConsole ? undefined : window.location.href, ) @@ -577,8 +576,7 @@ export class OsmConnection { await this.loadUserInfo() } - - private createAuthObject() { + private updateAuthObject(autoLogin: boolean) { let redirect_uri = Utils.runningFromConsole ? "https://mapcomplete.org/land.html" : window.location.protocol + "//" + window.location.host + "/land.html" @@ -594,7 +592,7 @@ export class OsmConnection { * However, this breaks in iframes so we open a popup in that case */ singlepage: !this._iframeMode && !AndroidPolyfill.inAndroid.data, - auto: false, + auto: autoLogin, apiUrl: this._oauth_config.api_url ?? this._oauth_config.url, }) if (AndroidPolyfill.inAndroid.data) { diff --git a/src/Logic/Osm/OsmPreferences.ts b/src/Logic/Osm/OsmPreferences.ts index f4472a3b1..1b2eddd07 100644 --- a/src/Logic/Osm/OsmPreferences.ts +++ b/src/Logic/Osm/OsmPreferences.ts @@ -209,7 +209,10 @@ export class OsmPreferences { * Bulk-downloads all preferences * @private */ - private getPreferencesDictDirectly(): Promise> { + private async getPreferencesDictDirectly(): Promise> { + if(!this.osmConnection.isLoggedIn.data){ + return {} + } return new Promise>((resolve, reject) => { this.auth.xhr( { @@ -257,6 +260,9 @@ export class OsmPreferences { * */ private async uploadKvSplit(k: string, v: string) { + if(!this.osmConnection.isLoggedIn.data){ + return + } if (v === null || v === undefined || v === "" || v === "undefined" || v === "null") { const keysToDelete = OsmPreferences.keysStartingWith(this.seenKeys, k) await Promise.all(keysToDelete.map((k) => this.deleteKeyDirectly(k))) @@ -280,7 +286,7 @@ export class OsmPreferences { */ private deleteKeyDirectly(k: string) { if (!this.osmConnection.isLoggedIn.data) { - console.debug(`Not saving preference ${k}: user not logged in`) + console.debug(`Not deleting preference ${k}: user not logged in`) return } diff --git a/src/UI/StatisticsGUI.ts b/src/UI/StatisticsGUI.ts index 90a3674e8..f3e659134 100644 --- a/src/UI/StatisticsGUI.ts +++ b/src/UI/StatisticsGUI.ts @@ -1,4 +1,5 @@ -import SvelteUIElement from "./Base/SvelteUIElement" import { default as StatisticsSvelte } from "../UI/Statistics/StatisticsGui.svelte" -new SvelteUIElement(StatisticsSvelte).AttachTo("main") +const target = document.getElementById("main") +target.innerHTML = "" +new StatisticsSvelte({ target }) diff --git a/src/index.ts b/src/index.ts index 030291a66..1edeb246b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,6 @@ async function main() { DetermineTheme.getTheme(), await getAvailableLayers(), ]) - availableLayers?.delete("cycle_highways") // TODO remove after next cache.mapcomplete.org update console.log("The available layers on server are", Array.from(availableLayers)) const state = new ThemeViewState(theme, availableLayers) const target = document.getElementById("maindiv")