forked from MapComplete/MapComplete
Chore: don't try to use localStorage when running from the console
This commit is contained in:
parent
84c46b35be
commit
4ff50fd92b
1 changed files with 15 additions and 13 deletions
|
|
@ -42,19 +42,21 @@ export class LocalStorageSource {
|
||||||
}
|
}
|
||||||
const source = new UIEventSource<string>(saved ?? defaultValue, "localstorage:" + key)
|
const source = new UIEventSource<string>(saved ?? defaultValue, "localstorage:" + key)
|
||||||
|
|
||||||
source.addCallback((data) => {
|
if(!Utils.runningFromConsole){
|
||||||
if (data === undefined || data === "" || data === null) {
|
source.addCallback((data) => {
|
||||||
localStorage.removeItem(key)
|
if (data === undefined || data === "" || data === null) {
|
||||||
return
|
localStorage.removeItem(key)
|
||||||
}
|
return
|
||||||
try {
|
}
|
||||||
localStorage.setItem(key, data)
|
try {
|
||||||
} catch (e) {
|
localStorage.setItem(key, data)
|
||||||
// Probably exceeded the quota with this item!
|
} catch (e) {
|
||||||
// Let's nuke everything
|
// Probably exceeded the quota with this item!
|
||||||
localStorage.clear()
|
// Let's nuke everything
|
||||||
}
|
localStorage.clear()
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
LocalStorageSource._cache[key] = source
|
LocalStorageSource._cache[key] = source
|
||||||
return source
|
return source
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue