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.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent a294ca7125
commit d9a27fcf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ui/app/components/app/menu-bar/menu-bar.js
  2. 4
      ui/app/store/actions.js

@ -26,7 +26,7 @@ export default function MenuBar () {
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false) const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false)
const origin = useSelector(getOriginOfCurrentTab) 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 ( return (
<div className="menu-bar"> <div className="menu-bar">

@ -1191,8 +1191,8 @@ export function showAccountDetail (address) {
const activeTabOrigin = state.activeTab.origin const activeTabOrigin = state.activeTab.origin
const selectedAddress = getSelectedAddress(state) const selectedAddress = getSelectedAddress(state)
const permittedAccountsForCurrentTab = getPermittedAccountsForCurrentTab(state) const permittedAccountsForCurrentTab = getPermittedAccountsForCurrentTab(state)
const currentTabIsConnectedToPreviousAddress = permittedAccountsForCurrentTab.includes(selectedAddress) const currentTabIsConnectedToPreviousAddress = Boolean(activeTabOrigin) && permittedAccountsForCurrentTab.includes(selectedAddress)
const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address) const currentTabIsConnectedToNextAddress = Boolean(activeTabOrigin) && permittedAccountsForCurrentTab.includes(address)
const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress
try { try {

Loading…
Cancel
Save