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

Commit ba295e6

Browse files
committed
Separate Out Pending Channels for Clashing
1 parent 553a6d6 commit ba295e6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/lightning-core/accounts/reducer.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const initialState = {
2626
channel: 0,
2727
},
2828
channels: [],
29+
pendingChannels: [],
2930
loadingChannels: false,
3031
}
3132

@@ -42,16 +43,21 @@ export default (state = initialState, action) => {
4243
case SET_BALANCES:
4344
return { ...state, balances: { ...state.balances, ...action.balances } }
4445
case PENDING_CHANNELS:
45-
case FETCH_CHANNELS:
4646
return {
4747
...state,
48-
channels: _.uniqBy([...action.channels, ...state.channels], 'channelPoint'),
48+
pendingChannels: action.pendingChannels,
4949
balances: {
5050
...state.balances,
51-
...(action.limboBalance !== undefined ? { limbo: action.limboBalance } : {}),
51+
limbo: action.limboBalance,
5252
},
5353
loadingChannels: false,
5454
}
55+
case FETCH_CHANNELS:
56+
return {
57+
...state,
58+
channels: action.channels,
59+
loadingChannels: false,
60+
}
5561
case START_CLOSING_CHANNEL:
5662
return {
5763
...state,
@@ -130,7 +136,7 @@ export const actions = {
130136
}))
131137

132138
return {
133-
channels: [
139+
pendingChannels: [
134140
...decorateChannels(data.pending_open_channels, () => ({ status: 'pending-open' })),
135141
...decorateChannels(data.pending_closing_channels, () => ({ status: 'pending-closing' })),
136142
...decorateChannels(data.pending_force_closing_channels, () => ({ status: 'pending-force-closing' })),
@@ -289,6 +295,9 @@ export const selectors = {
289295
getAccountPubkey: state => state.pubkey,
290296
getCurrency: state => state.currency,
291297
getAccountBalances: state => state.balances,
292-
getChannels: state => state.channels || [],
298+
getChannels: (state) => {
299+
const channels = [...state.channels, ...state.pendingChannels]
300+
return channels.length ? channels : []
301+
},
293302
getChannelsLoading: state => state.loadingChannels,
294303
}

0 commit comments

Comments
 (0)