@samitouri / QOS-React / commits / 26162988aa

Fix tests

Dan Abramov committed Apr 23, 2019 at 17:10 UTC 26162988aa7f923b95b413ce9c6ec1503113162a
1 file changed +13 -9
src/backend/agent.js
+13 -9
@@ -81,11 +81,13 @@ export default class Agent extends EventEmitter {
81 localStorage.removeItem(LOCAL_STORAGE_RELOAD_AND_PROFILE_KEY);
82 }
83
84 - const persistedSelectionString = sessionStorage.getItem(
85 - SESSION_STORAGE_LAST_SELECTION_KEY
86 - );
87 - if (persistedSelectionString != null) {
88 - this._persistedSelection = JSON.parse(persistedSelectionString);
84 + if (typeof sessionStorage !== 'undefined') {
85 + const persistedSelectionString = sessionStorage.getItem(
86 + SESSION_STORAGE_LAST_SELECTION_KEY
87 + );
88 + if (persistedSelectionString != null) {
89 + this._persistedSelection = JSON.parse(persistedSelectionString);
90 + }
91 }
92 }
93
@@ -617,9 +619,11 @@ export default class Agent extends EventEmitter {
619 if (path === null) {
620 return;
621 }
620 - sessionStorage.setItem(
621 - SESSION_STORAGE_LAST_SELECTION_KEY,
622 - JSON.stringify(({ rendererID, path }: PersistedSelection))
623 - );
622 + if (typeof sessionStorage !== 'undefined') {
623 + sessionStorage.setItem(
624 + SESSION_STORAGE_LAST_SELECTION_KEY,
625 + JSON.stringify(({ rendererID, path }: PersistedSelection))
626 + );
627 + }
628 }, 1000);
629 }