Delete stale paths
Dan Abramov committed
Apr 24, 2019 at 15:02 UTC
5d2d4213ec3d100b3245f8a3788bbc62c7361cef
1 file changed
+9
-11
src/backend/agent.js
+9
-11
@@ -608,18 +608,16 @@ export default class Agent extends EventEmitter {
608
// might not be available by the time we read them.
609
// This is why we need the defensive checks here.
610
const renderer = this._rendererInterfaces[rendererID];
611
- if (renderer == null) {
612
- return;
613
- }
614
- const path = renderer.getPathForElement(id);
615
- if (path === null) {
616
- return;
617
- }
611
+ const path = renderer != null ? renderer.getPathForElement(id) : null;
612
if (typeof sessionStorage !== 'undefined') {
619
- sessionStorage.setItem(
620
- SESSION_STORAGE_LAST_SELECTION_KEY,
621
- JSON.stringify(({ rendererID, path }: PersistedSelection))
622
- );
613
+ if (path !== null) {
614
+ sessionStorage.setItem(
615
+ SESSION_STORAGE_LAST_SELECTION_KEY,
616
+ JSON.stringify(({ rendererID, path }: PersistedSelection))
617
+ );
618
+ } else {
619
+ sessionStorage.removeItem(SESSION_STORAGE_LAST_SELECTION_KEY);
620
+ }
621
}
622
}, 1000);
623
}