Window.getState: return default if prop not in obj
If the requested object in states.json exists but doesn't contain the property we're looking for, return the default value (passed to the function) instead of undefined.
This commit is contained in:
@@ -52,7 +52,8 @@ ApplicationWindow {
|
||||
|
||||
function getState(obj, property, defaultValue=undefined) {
|
||||
try {
|
||||
return uiState[obj.saveName][obj.saveId || "ALL"][property]
|
||||
const props = uiState[obj.saveName][obj.saveId || "ALL"]
|
||||
return property in props ? props[property] : defaultValue
|
||||
} catch(err) {
|
||||
return defaultValue
|
||||
}
|
||||
|
Reference in New Issue
Block a user