Merge develop

This commit is contained in:
Pieter Vander Vennet 2025-01-22 02:43:40 +01:00
commit 87a061bdd4
4 changed files with 17 additions and 13 deletions

View file

@ -135,7 +135,7 @@ export class OsmConnection {
oauth_token?: UIEventSource<string> oauth_token?: UIEventSource<string>
// Used to keep multiple changesets open and to write to the correct changeset // Used to keep multiple changesets open and to write to the correct changeset
singlePage?: boolean singlePage?: boolean
attemptLogin?: true | boolean attemptLogin?: boolean
/** /**
* If true: automatically check if we're still online every 5 minutes + fetch messages * 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<boolean>(false) this._dryRun = options.dryRun ?? new UIEventSource<boolean>(false)
this.createAuthObject() this.updateAuthObject(false)
AndroidPolyfill.inAndroid.addCallback(() => { AndroidPolyfill.inAndroid.addCallback(() => {
this.createAuthObject() this.updateAuthObject(false)
}) })
if (!this.fakeUser) { if (!this.fakeUser) {
this.CheckForMessagesContinuously() this.CheckForMessagesContinuously()
@ -261,8 +261,7 @@ export class OsmConnection {
console.log("AttemptLogin called, but ignored as fakeUser is set") console.log("AttemptLogin called, but ignored as fakeUser is set")
return return
} }
this.updateAuthObject(true)
console.log("Trying to log in...")
LocalStorageSource.get("location_before_login").setData( LocalStorageSource.get("location_before_login").setData(
Utils.runningFromConsole ? undefined : window.location.href, Utils.runningFromConsole ? undefined : window.location.href,
) )
@ -577,8 +576,7 @@ export class OsmConnection {
await this.loadUserInfo() await this.loadUserInfo()
} }
private updateAuthObject(autoLogin: boolean) {
private createAuthObject() {
let redirect_uri = Utils.runningFromConsole let redirect_uri = Utils.runningFromConsole
? "https://mapcomplete.org/land.html" ? "https://mapcomplete.org/land.html"
: window.location.protocol + "//" + window.location.host + "/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 * However, this breaks in iframes so we open a popup in that case
*/ */
singlepage: !this._iframeMode && !AndroidPolyfill.inAndroid.data, singlepage: !this._iframeMode && !AndroidPolyfill.inAndroid.data,
auto: false, auto: autoLogin,
apiUrl: this._oauth_config.api_url ?? this._oauth_config.url, apiUrl: this._oauth_config.api_url ?? this._oauth_config.url,
}) })
if (AndroidPolyfill.inAndroid.data) { if (AndroidPolyfill.inAndroid.data) {

View file

@ -209,7 +209,10 @@ export class OsmPreferences {
* Bulk-downloads all preferences * Bulk-downloads all preferences
* @private * @private
*/ */
private getPreferencesDictDirectly(): Promise<Record<string, string>> { private async getPreferencesDictDirectly(): Promise<Record<string, string>> {
if(!this.osmConnection.isLoggedIn.data){
return {}
}
return new Promise<Record<string, string>>((resolve, reject) => { return new Promise<Record<string, string>>((resolve, reject) => {
this.auth.xhr( this.auth.xhr(
{ {
@ -257,6 +260,9 @@ export class OsmPreferences {
* *
*/ */
private async uploadKvSplit(k: string, v: string) { private async uploadKvSplit(k: string, v: string) {
if(!this.osmConnection.isLoggedIn.data){
return
}
if (v === null || v === undefined || v === "" || v === "undefined" || v === "null") { if (v === null || v === undefined || v === "" || v === "undefined" || v === "null") {
const keysToDelete = OsmPreferences.keysStartingWith(this.seenKeys, k) const keysToDelete = OsmPreferences.keysStartingWith(this.seenKeys, k)
await Promise.all(keysToDelete.map((k) => this.deleteKeyDirectly(k))) await Promise.all(keysToDelete.map((k) => this.deleteKeyDirectly(k)))
@ -280,7 +286,7 @@ export class OsmPreferences {
*/ */
private deleteKeyDirectly(k: string) { private deleteKeyDirectly(k: string) {
if (!this.osmConnection.isLoggedIn.data) { 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 return
} }

View file

@ -1,4 +1,5 @@
import SvelteUIElement from "./Base/SvelteUIElement"
import { default as StatisticsSvelte } from "../UI/Statistics/StatisticsGui.svelte" import { default as StatisticsSvelte } from "../UI/Statistics/StatisticsGui.svelte"
new SvelteUIElement(StatisticsSvelte).AttachTo("main") const target = document.getElementById("main")
target.innerHTML = ""
new StatisticsSvelte({ target })

View file

@ -54,7 +54,6 @@ async function main() {
DetermineTheme.getTheme(), DetermineTheme.getTheme(),
await getAvailableLayers(), 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)) console.log("The available layers on server are", Array.from(availableLayers))
const state = new ThemeViewState(theme, availableLayers) const state = new ThemeViewState(theme, availableLayers)
const target = document.getElementById("maindiv") const target = document.getElementById("maindiv")