Stabilize personal theme, textfield now correctly appears if it is an option in the freeform too

This commit is contained in:
Pieter Vander Vennet 2021-02-20 01:45:51 +01:00
parent 79fc3f54e5
commit 416a76ae4f
22 changed files with 278 additions and 149 deletions

View file

@ -9,18 +9,21 @@ export default class LocalStorageSource implements FeatureSource {
constructor(layout: UIEventSource<LayoutConfig>) {
this.features = new UIEventSource<{ feature: any; freshness: Date }[]>([])
const key = LocalStorageSaver.storageKey + layout.data.id
try {
const fromStorage = localStorage.getItem(key);
if (fromStorage == null) {
return;
}
const loaded = JSON.parse(fromStorage);
this.features.setData(loaded);
console.log("Loaded ",loaded.length," features from localstorage as cache")
} catch (e) {
console.log("Could not load features from localStorage:", e)
localStorage.removeItem(key)
}
layout.addCallbackAndRun(_ => {
try {
const fromStorage = localStorage.getItem(key);
if (fromStorage == null) {
return;
}
const loaded = JSON.parse(fromStorage);
this.features.setData(loaded);
console.log("Loaded ", loaded.length, " features from localstorage as cache")
} catch (e) {
console.log("Could not load features from localStorage:", e)
localStorage.removeItem(key)
}
})
}
}