Delete stale paths

This commit is contained in:
Dan Abramov
2019-04-24 15:05:21 +01:00
parent e050529c7d
commit 5d2d4213ec
+9 -11
View File
@@ -608,18 +608,16 @@ export default class Agent extends EventEmitter {
// might not be available by the time we read them.
// This is why we need the defensive checks here.
const renderer = this._rendererInterfaces[rendererID];
if (renderer == null) {
return;
}
const path = renderer.getPathForElement(id);
if (path === null) {
return;
}
const path = renderer != null ? renderer.getPathForElement(id) : null;
if (typeof sessionStorage !== 'undefined') {
sessionStorage.setItem(
SESSION_STORAGE_LAST_SELECTION_KEY,
JSON.stringify(({ rendererID, path }: PersistedSelection))
);
if (path !== null) {
sessionStorage.setItem(
SESSION_STORAGE_LAST_SELECTION_KEY,
JSON.stringify(({ rendererID, path }: PersistedSelection))
);
} else {
sessionStorage.removeItem(SESSION_STORAGE_LAST_SELECTION_KEY);
}
}
}, 1000);
}