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:
miruka 2020-07-14 16:56:00 -04:00
parent d51c0e3e5d
commit a65163df27

View File

@ -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
}