Browse Source

feature(waitingChannels): add waiting close channels support to allChannels selector

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
6be387291d
  1. 39
      app/reducers/channels.js

39
app/reducers/channels.js

@ -337,7 +337,30 @@ const ACTION_HANDLERS = {
[GET_CHANNELS]: state => ({ ...state, channelsLoading: true }), [GET_CHANNELS]: state => ({ ...state, channelsLoading: true }),
[RECEIVE_CHANNELS]: (state, { channels, pendingChannels }) => ( [RECEIVE_CHANNELS]: (state, { channels, pendingChannels }) => (
{ {
...state, channelsLoading: false, channels, pendingChannels ...state, channelsLoading: false, channels, pendingChannels: {
waiting_close_channels: [
{
"channel": {
"remote_node_pub": "033e90d7d899d83b1e6485b8fe63244c32aaf0f7f4ead86df08c0d8298cf6fa32d",
"channel_point": "cec3602132c7a0de92759f0600b88f2650b8a8b42b96dd363b29880bfdd601aa:0",
"capacity": "16777216",
"local_balance": "16768166",
"remote_balance": "0"
},
"closing_txid": "7b62a6af682e9ea68498b3c02f23b8876749342163a4a5f36dd4e449e43112e3",
"limbo_balance": "16768166",
"maturity_height": 1297940,
"blocks_til_maturity": 2016,
"recovered_balance": "0",
"pending_htlcs": [
]
}
],
total_limbo_balance: '',
pending_open_channels: [],
pending_closing_channels: [],
pending_force_closing_channels: []
},
} }
), ),
@ -380,6 +403,7 @@ const channelsSelector = state => state.channels.channels
const pendingOpenChannelsSelector = state => state.channels.pendingChannels.pending_open_channels const pendingOpenChannelsSelector = state => state.channels.pendingChannels.pending_open_channels
const pendingClosedChannelsSelector = state => state.channels.pendingChannels.pending_closing_channels const pendingClosedChannelsSelector = state => state.channels.pendingChannels.pending_closing_channels
const pendingForceClosedChannelsSelector = state => state.channels.pendingChannels.pending_force_closing_channels const pendingForceClosedChannelsSelector = state => state.channels.pendingChannels.pending_force_closing_channels
const waitingCloseChannelsSelector = state => state.channels.pendingChannels.waiting_close_channels
const channelSearchQuerySelector = state => state.channels.searchQuery const channelSearchQuerySelector = state => state.channels.searchQuery
const filtersSelector = state => state.channels.filters const filtersSelector = state => state.channels.filters
const filterSelector = state => state.channels.filter const filterSelector = state => state.channels.filter
@ -453,8 +477,9 @@ const allChannels = createSelector(
pendingOpenChannelsSelector, pendingOpenChannelsSelector,
pendingClosedChannelsSelector, pendingClosedChannelsSelector,
pendingForceClosedChannelsSelector, pendingForceClosedChannelsSelector,
waitingCloseChannelsSelector,
channelSearchQuerySelector, channelSearchQuerySelector,
(activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, searchQuery) => { (activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, waitingCloseChannels, searchQuery) => {
const filterChannel = channel => const filterChannel = channel =>
channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery) channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)
@ -467,14 +492,18 @@ const allChannels = createSelector(
const filteredPendingOpenChannels = pendingOpenChannels.filter(filterPendingChannel) const filteredPendingOpenChannels = pendingOpenChannels.filter(filterPendingChannel)
const filteredPendingClosedChannels = pendingClosedChannels.filter(filterPendingChannel) const filteredPendingClosedChannels = pendingClosedChannels.filter(filterPendingChannel)
const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel) const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel)
const filteredWaitingCloseChannels = waitingCloseChannels.filter(filterPendingChannel)
return [ return [
...filteredActiveChannels, ...filteredActiveChannels,
...filteredPendingOpenChannels, ...filteredPendingOpenChannels,
...filteredPendingClosedChannels, ...filteredPendingClosedChannels,
...filteredPendingForcedClosedChannels, ...filteredPendingForcedClosedChannels,
...filteredNonActiveChannels ...filteredNonActiveChannels,
...filteredWaitingCloseChannels
] ]
} }
) )
@ -508,6 +537,7 @@ export const currentChannels = createSelector(
} }
} }
const channelArray = filteredArray(channelFilter.key) const channelArray = filteredArray(channelFilter.key)
return channelArray.filter(channel => (Object.prototype.hasOwnProperty.call(channel, 'channel') ? return channelArray.filter(channel => (Object.prototype.hasOwnProperty.call(channel, 'channel') ?
@ -529,7 +559,8 @@ const initialState = {
total_limbo_balance: '', total_limbo_balance: '',
pending_open_channels: [], pending_open_channels: [],
pending_closing_channels: [], pending_closing_channels: [],
pending_force_closing_channels: [] pending_force_closing_channels: [],
waiting_close_channels: []
}, },
channel: null, channel: null,
channelForm: { channelForm: {

Loading…
Cancel
Save