|
@@ -9,14 +9,26 @@ interface ILineContainerComponentProps {
|
|
|
}
|
|
|
|
|
|
export class LineContainerComponent extends React.Component<ILineContainerComponentProps, { isExpanded: boolean }> {
|
|
|
+ private static _InMemoryStorage: {[key: string]: boolean};
|
|
|
+
|
|
|
constructor(props: ILineContainerComponentProps) {
|
|
|
super(props);
|
|
|
|
|
|
let initialState: boolean;
|
|
|
|
|
|
- if (typeof (Storage) !== "undefined" && localStorage.getItem(this.props.title) !== null) {
|
|
|
- initialState = localStorage.getItem(this.props.title) === "true";
|
|
|
- } else {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (LineContainerComponent._InMemoryStorage && LineContainerComponent._InMemoryStorage[this.props.title] !== undefined) {
|
|
|
+ initialState = LineContainerComponent._InMemoryStorage[this.props.title];
|
|
|
+ } else if (typeof (Storage) !== "undefined" && localStorage.getItem(this.props.title) !== null) {
|
|
|
+ initialState = localStorage.getItem(this.props.title) === "true";
|
|
|
+ } else {
|
|
|
+ initialState = !this.props.closed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ LineContainerComponent._InMemoryStorage = {};
|
|
|
+ LineContainerComponent._InMemoryStorage[this.props.title] = !this.props.closed
|
|
|
initialState = !this.props.closed;
|
|
|
}
|
|
|
|
|
@@ -24,10 +36,23 @@ export class LineContainerComponent extends React.Component<ILineContainerCompon
|
|
|
}
|
|
|
|
|
|
switchExpandedState(): void {
|
|
|
- if (typeof (Storage) !== "undefined") {
|
|
|
- localStorage.setItem(this.props.title, !this.state.isExpanded ? "true" : "false");
|
|
|
+ const newState = !this.state.isExpanded;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (LineContainerComponent._InMemoryStorage) {
|
|
|
+ LineContainerComponent._InMemoryStorage[this.props.title] = newState;
|
|
|
+ } else if (typeof (Storage) !== "undefined") {
|
|
|
+ localStorage.setItem(this.props.title, newState ? "true" : "false");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ LineContainerComponent._InMemoryStorage = {};
|
|
|
+ LineContainerComponent._InMemoryStorage[this.props.title] = newState;
|
|
|
}
|
|
|
- this.setState({ isExpanded: !this.state.isExpanded });
|
|
|
+
|
|
|
+ this.setState({ isExpanded: newState });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
renderHeader() {
|