From 5d2d4213ec3d100b3245f8a3788bbc62c7361cef Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 24 Apr 2019 15:02:52 +0100 Subject: [PATCH] Delete stale paths --- src/backend/agent.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/backend/agent.js b/src/backend/agent.js index dee69506cb..976b838c88 100644 --- a/src/backend/agent.js +++ b/src/backend/agent.js @@ -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); }