From d9a27fcf5220f214ccc8f48345eb62b630f507f1 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 2 Jul 2020 18:26:30 -0300 Subject: [PATCH] Prevent showing connected accounts without origin (#8891) There was a case where the `activeTab.origin` was not set, yet the user could still navigate to the "Connected accounts" modal, which assumes that `activeTab.origin` is set. This would happen in Firefox when the user opened the popup on a page internal to Firefox (e.g. `about:blank`). The connected status indicator would still be shown, but the UI would crash when it was clicked. The connected status indicator is now hidden whenever `activeTab.origin` is falsy. The 'Unconnected account' alert has also been made impossible to trigger in that circumstance. --- ui/app/components/app/menu-bar/menu-bar.js | 2 +- ui/app/store/actions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/components/app/menu-bar/menu-bar.js b/ui/app/components/app/menu-bar/menu-bar.js index 99bc50afa..282307f59 100644 --- a/ui/app/components/app/menu-bar/menu-bar.js +++ b/ui/app/components/app/menu-bar/menu-bar.js @@ -26,7 +26,7 @@ export default function MenuBar () { const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false) const origin = useSelector(getOriginOfCurrentTab) - const showStatus = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP && origin !== extension.runtime.id + const showStatus = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP && origin && origin !== extension.runtime.id return (
diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index f139d71a0..d05b03214 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -1191,8 +1191,8 @@ export function showAccountDetail (address) { const activeTabOrigin = state.activeTab.origin const selectedAddress = getSelectedAddress(state) const permittedAccountsForCurrentTab = getPermittedAccountsForCurrentTab(state) - const currentTabIsConnectedToPreviousAddress = permittedAccountsForCurrentTab.includes(selectedAddress) - const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address) + const currentTabIsConnectedToPreviousAddress = Boolean(activeTabOrigin) && permittedAccountsForCurrentTab.includes(selectedAddress) + const currentTabIsConnectedToNextAddress = Boolean(activeTabOrigin) && permittedAccountsForCurrentTab.includes(address) const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress try {