From 2d576e5757504e0e54ddd8c922bd930ad91207b7 Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Wed, 21 Feb 2018 16:12:46 -0800 Subject: [PATCH] tabs: only replace permanent contents --- app/browser/tabs.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/browser/tabs.js b/app/browser/tabs.js index b64dd65cc61..1f2c07cb611 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -620,10 +620,17 @@ const api = { }) tab.on('tab-replaced-at', (e, windowId, tabIndex, newContents) => { - console.log(`tab ${tab.getId()} changed to`, {newTabId: newContents.getId(), tabIndex}) + const isPlaceholder = newContents.isPlaceholder() const newTabId = newContents.getId() + if (isPlaceholder) { + if (shouldDebugTabEvents) { + console.log(`Tab [${tabId}] got a new placeholder (${newTabId}), not updating state.`) + } + return + } + // new contents is permanent replacement, e.g. tab has been discarded if (shouldDebugTabEvents) { - console.log(`Tab [${tabId}] changed to tabId ${newTabId}. Updating state references...`) + console.log(`Tab [${tabId}] permanently changed to tabId ${newTabId}. Updating state references...`) } // update state appActions.tabReplaced(tabId, getTabValue(newTabId), getTabValue(tabId).get('windowId'))