safer access to localStorage initial state

ie. legacy localStorage having `expanded` but not `multiline`
This commit is contained in:
David Tsay 2024-09-20 15:58:35 -07:00
parent e494bee1ff
commit a54affd36d

View File

@ -208,13 +208,15 @@ export default {
}, },
inject: ['openmct'], inject: ['openmct'],
data: function () { data: function () {
let storedHeadProps = window.localStorage.getItem('openmct-shell-head'); const DEFAULT_HEAD_EXPANDED = true;
let headExpanded = true; const DEFAULT_INDICATORS_MULTILINE = true;
let indicatorsMultiline = true;
if (storedHeadProps) { const storedHeadProps = JSON.parse(localStorage.getItem('openmct-shell-head'));
headExpanded = JSON.parse(storedHeadProps).expanded; const storedHeadExpanded = storedHeadProps?.expanded;
indicatorsMultiline = JSON.parse(storedHeadProps).multiline; const storedIndicatorsMultiline = storedHeadProps?.multiline;
}
const headExpanded = storedHeadExpanded ?? DEFAULT_HEAD_EXPANDED;
const indicatorsMultiline = storedIndicatorsMultiline ?? DEFAULT_INDICATORS_MULTILINE;
return { return {
fullScreen: false, fullScreen: false,