Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit a6fc5b6

Browse files
committed
Put Channel in Closing Status
1 parent e91c37d commit a6fc5b6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/lightning-core/accounts/ChannelListItem.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
8686
background: 'light-gray',
8787
},
8888
},
89-
}, { hover, pending: status !== 'open' })
89+
}, { hover, pending: status === 'pending' || status === 'closing' })
9090

9191
const PROMPT = 'CHANNEL_LIST/PROMPT'
9292

@@ -118,7 +118,7 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
118118
<div style={ styles.split }>
119119
<div style={ styles.id }>
120120
{ status === 'pending' ? 'PENDING' : `CID:${ id }` }
121-
{ status !== 'pending' && (
121+
{ status !== 'pending' && status !== 'closing' && (
122122
<div style={ styles.closeLabel } onClick={ showPopupOrClose }>
123123
<Icon small name="close" />
124124
</div>
@@ -159,7 +159,7 @@ export default connect(
159159
() => ({}), {
160160
onShowPopup: popupActions.onOpen,
161161
onClosePopup: popupActions.onClose,
162-
onCloseChannel: actions.closeChannel,
162+
onCloseChannel: actions.startCloseChannel,
163163
onSuccess: notificationActions.addNotification,
164164
onFetchChannels: accountsActions.fetchChannels,
165165
},

packages/lightning-core/accounts/reducer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const FETCH_CHANNELS_FAILURE = 'ACCOUNTS/FETCH_CHANNELS_FAILURE'
1111
export const LIST_PEERS = 'ACCOUNTS/LIST_PEERS'
1212
export const OPEN_CHANNEL = 'ACCOUNTS/OPEN_CHANNEL'
1313
export const CONNECT_PEER = 'ACCOUNTS/CONNECT_PEER'
14+
export const START_CLOSING_CHANNEL = 'ACCOUNTS/START_CLOSING_CHANNEL'
1415
export const CLOSE_CHANNEL = 'ACCOUNTS/CLOSE_CHANNEL'
1516
export const PENDING_CHANNELS = 'ACCOUNTS/PENDING_CHANNELS'
1617
export const FETCH_ACCOUNT_FAILURE = 'ACCOUNTS/FETCH_ACCOUNT_ERROR'
@@ -47,6 +48,19 @@ export default (state = initialState, action) => {
4748
channels: _.uniqBy([...action.channels, ...state.channels], 'channelPoint'),
4849
loadingChannels: false,
4950
}
51+
case START_CLOSING_CHANNEL:
52+
return {
53+
...state,
54+
channels: _.map(state.channels, (c) => {
55+
if (c.channelPoint === action.channelPoint) {
56+
return {
57+
...c,
58+
status: 'closing',
59+
}
60+
}
61+
return c
62+
}),
63+
}
5064
case FETCH_CHANNELS_FAILURE:
5165
return { ...state, channels: [], loadingChannels: false }
5266
default: return state
@@ -200,6 +214,10 @@ export const actions = {
200214
.catch(rejectError)
201215
})
202216
},
217+
startCloseChannel: params => (dispatch) => {
218+
dispatch({ type: START_CLOSING_CHANNEL, channelPoint: params.channelPoint })
219+
return dispatch(actions.closeChannel(params))
220+
},
203221
closeChannel: ({ channelPoint, force = false }) => {
204222
const txid = channelPoint.split(':')[0]
205223
const index = channelPoint.split(':')[1]

0 commit comments

Comments
 (0)