Skip to content

Commit

Permalink
Tidy up status indicator container logic
Browse files Browse the repository at this point in the history
  • Loading branch information
whymarrh committed Apr 1, 2020
1 parent 457bd36 commit 0d7dce8
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { findKey } from 'lodash'
import { connect } from 'react-redux'
import ConnectedStatusIndicator from './connected-status-indicator.component'
import {
Expand All @@ -18,17 +19,12 @@ const mapStateToProps = (state) => {
const originOfCurrentTab = getOriginOfCurrentTab(state)

const selectedAddressDomainMap = addressConnectedDomainMap[selectedAddress]
const currentTabIsConnectedToSelectedAddress = selectedAddressDomainMap && selectedAddressDomainMap[originOfCurrentTab]

const allConnectedDomains = Object.values(addressConnectedDomainMap).reduce((acc, val) => {
return { ...acc, ...val }
}, {})
const currentTabIsConnectToSomeOtherAddress = !currentTabIsConnectedToSelectedAddress && allConnectedDomains[originOfCurrentTab]
const currentTabIsConnectedToSelectedAddress = Boolean(selectedAddressDomainMap && selectedAddressDomainMap[originOfCurrentTab])

let status
if (currentTabIsConnectedToSelectedAddress) {
status = STATUS_CONNECTED
} else if (currentTabIsConnectToSomeOtherAddress) {
} else if (findKey(addressConnectedDomainMap, originOfCurrentTab)) {
status = STATUS_CONNECTED_TO_ANOTHER_ACCOUNT
} else {
status = STATUS_NOT_CONNECTED
Expand Down

0 comments on commit 0d7dce8

Please sign in to comment.