forked from MapComplete/MapComplete
Fix: stabilize user settings
This commit is contained in:
parent
6c9f660938
commit
4fd76cfce7
3 changed files with 21 additions and 7 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue