Skip to content
Permalink
Browse files

fix(channels): prevent crash when closing a channel

fix #1996
  • Loading branch information...
korhaliv committed Apr 12, 2019
1 parent 8e97c05 commit 76c6b2d40b1965adc22ab65345532e5b979dec34
Showing with 33 additions and 37 deletions.
  1. +30 −28 renderer/components/Channels/ChannelDetail.js
  2. +2 −8 renderer/containers/ModalStack.js
  3. +1 −1 renderer/reducers/utils.js
@@ -14,37 +14,39 @@ const ChannelDetail = ({
setSelectedChannel,
networkInfo,
...rest
}) => (
<Panel {...rest}>
<Panel.Header mx="auto" width={9 / 16}>
<ChannelHeader channel={channel} />
</Panel.Header>
<Panel.Body css={{ 'overflow-y': 'overlay', 'overflow-x': 'hidden' }}>
<ChannelCapacity
localBalance={channel.local_balance}
mx="auto"
my={4}
remoteBalance={channel.remote_balance}
width={9 / 16}
/>
<ChannelData
channel={channel}
currencyName={currencyName}
mx="auto"
networkInfo={networkInfo}
viewMode={CHANNEL_DATA_VIEW_MODE_FULL}
width={9 / 16}
/>
</Panel.Body>
}) => {
return channel ? (
<Panel {...rest}>
<Panel.Header mx="auto" width={9 / 16}>
<ChannelHeader channel={channel} />
</Panel.Header>
<Panel.Body css={{ 'overflow-y': 'overlay', 'overflow-x': 'hidden' }}>
<ChannelCapacity
localBalance={channel.local_balance}
mx="auto"
my={4}
remoteBalance={channel.remote_balance}
width={9 / 16}
/>
<ChannelData
channel={channel}
currencyName={currencyName}
mx="auto"
networkInfo={networkInfo}
viewMode={CHANNEL_DATA_VIEW_MODE_FULL}
width={9 / 16}
/>
</Panel.Body>

<Panel.Footer mt={2} px={4}>
<ChannelFooter channel={channel} closeChannel={closeChannel} />
</Panel.Footer>
</Panel>
)
<Panel.Footer mt={2} px={4}>
<ChannelFooter channel={channel} closeChannel={closeChannel} />
</Panel.Footer>
</Panel>
) : null
}

ChannelDetail.propTypes = {
channel: PropTypes.object.isRequired,
channel: PropTypes.object,
closeChannel: PropTypes.func.isRequired,
currencyName: PropTypes.string.isRequired,
networkInfo: PropTypes.shape({
@@ -9,8 +9,7 @@ import { useOnKeydown } from 'hooks'
import Pay from 'containers/Pay'
import Request from 'containers/Request'
import Channels from 'containers/Channels'
import ChannelCloseDialog from 'containers/Channels/ChannelCloseDialog'
import ChannelDetail from 'containers/Channels/ChannelDetail'
import ChannelDetailModal from 'containers/Channels/ChannelDetailModal'
import ChannelCreate from 'containers/Channels/ChannelCreate'
import ReceiveModal from 'containers/Wallet/ReceiveModal'
import ActivityModal from 'containers/Activity/ActivityModal'
@@ -40,12 +39,7 @@ const ModalContent = ({ type, closeModal }) => {
return <ChannelCreate mx={-4} onSubmit={() => closeModal()} />

case 'CHANNEL_DETAIL':
return (
<>
<ChannelDetail mx={-4} />
<ChannelCloseDialog />
</>
)
return <ChannelDetailModal type="CHANNEL_DETAIL" />
}
}

@@ -90,7 +90,7 @@ export const decoratedSelectedChannel = createSelector(
transactionsSelectors.rawTransactionsSelector,
channelsSelectors.selectedChannel,
(transactions, channelData) => {
if (channelData.channel_point) {
if (channelData && channelData.channel_point) {
const [funding_txid] = channelData.channel_point.split(':')
// cross reference funding tx
const fundingTx = funding_txid && transactions.find(tx => tx.tx_hash === funding_txid)

0 comments on commit 76c6b2d

Please sign in to comment.
You can’t perform that action at this time.