Fix: stabilize user settings

This commit is contained in:
Pieter Vander Vennet 2025-06-16 20:30:51 +02:00
parent 6c9f660938
commit 4fd76cfce7
3 changed files with 21 additions and 7 deletions

View file

@ -71,8 +71,8 @@ export class OsmPreferences {
if (value) {
this.setPreferencesAll(key, value, deferPing)
}
pref.addCallback((v) => {
this.uploadKvSplit(key, v)
pref.addCallback(async (v) => {
await this.uploadKvSplit(key, v)
this.setPreferencesAll(key, v, deferPing)
})
return pref
@ -270,20 +270,27 @@ export class OsmPreferences {
return
}
// _All_ keys are deleted first, to avoid pending parts
const keysToDelete = OsmPreferences.keysStartingWith(this.seenKeys, k)
await Promise.all(keysToDelete.map((k) => this.deleteKeyDirectly(k)))
const keysToDelete = Utils.Dedup(OsmPreferences.keysStartingWith(this.seenKeys, k))
if (v === null || v === undefined || v === "" || v === "undefined" || v === "null") {
for (const k of keysToDelete) {
await this.deleteKeyDirectly(k)
}
return
}
const restingKeys = new Set(keysToDelete)
restingKeys.delete(k)
await this.uploadKeyDirectly(k, v.slice(0, 255))
v = v.slice(255)
let i = 0
while (v.length > 0) {
restingKeys.delete(`${k}:${i}`)
await this.uploadKeyDirectly(`${k}:${i}`, v.slice(0, 255))
v = v.slice(255)
i++
}
for (const k of restingKeys) {
await this.deleteKeyDirectly(k)
}
}
/**

View file

@ -644,7 +644,9 @@ export default class UserRelatedState {
}
const pref = this.osmConnection.GetPreference(key, undefined, { prefix: "" })
pref.set(tags[key])
if (pref.data !== tags[key]) {
pref.set(tags[key])
}
}
})

View file

@ -756,7 +756,12 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
}
if (!showScale) {
if (this.scaleControl) {
map.removeControl(this.scaleControl)
try {
map.removeControl(this.scaleControl)
} catch (e) {
console.warn("Could not remove scale control, underlying map might have had a reset")
}
this.scaleControl = undefined
}
return