Full code cleanup

This commit is contained in:
Pieter Vander Vennet 2022-01-26 21:40:38 +01:00
parent 3a4a2a2016
commit fa971ffbbf
300 changed files with 16352 additions and 19284 deletions

View file

@ -122,6 +122,34 @@ export class OsmPreferences {
return pref;
}
public ClearPreferences() {
let isRunning = false;
const self = this;
this.preferences.addCallbackAndRun(prefs => {
if (Object.keys(prefs).length == 0) {
return;
}
if (isRunning) {
return
}
isRunning = true
const prefixes = ["mapcomplete-installed-theme", "mapcomplete-installed-themes-", "mapcomplete-current-open-changeset", "mapcomplete-personal-theme-layer"]
for (const key in prefs) {
for (const prefix of prefixes) {
// console.log(key)
if (key.startsWith(prefix)) {
console.log("Clearing ", key)
self.GetPreference(key, "").setData("")
}
}
}
isRunning = false;
return true;
})
}
private UpdatePreferences() {
const self = this;
this.auth.xhr({
@ -184,34 +212,6 @@ export class OsmPreferences {
console.debug(`Preference ${k} written!`);
});
}
public ClearPreferences(){
let isRunning = false;
const self = this;
this.preferences.addCallbackAndRun(prefs => {
if(Object.keys(prefs).length == 0){
return;
}
if (isRunning) {
return
}
isRunning = true
const prefixes = ["mapcomplete-installed-theme","mapcomplete-installed-themes-","mapcomplete-current-open-changeset","mapcomplete-personal-theme-layer"]
for (const key in prefs) {
for (const prefix of prefixes) {
// console.log(key)
if (key.startsWith(prefix)) {
console.log("Clearing ", key)
self.GetPreference(key, "").setData("")
}
}
}
isRunning = false;
return true;
})
}
}