From 6be387291d5abff29198d5320557ccb6eeb59bae Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Sat, 5 May 2018 00:26:31 -0500 Subject: [PATCH 1/2] feature(waitingChannels): add waiting close channels support to allChannels selector --- app/reducers/channels.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 9c019fd0..f539c966 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -337,7 +337,30 @@ const ACTION_HANDLERS = { [GET_CHANNELS]: state => ({ ...state, channelsLoading: true }), [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 pendingClosedChannelsSelector = state => state.channels.pendingChannels.pending_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 filtersSelector = state => state.channels.filters const filterSelector = state => state.channels.filter @@ -453,8 +477,9 @@ const allChannels = createSelector( pendingOpenChannelsSelector, pendingClosedChannelsSelector, pendingForceClosedChannelsSelector, + waitingCloseChannelsSelector, channelSearchQuerySelector, - (activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, searchQuery) => { + (activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, waitingCloseChannels, searchQuery) => { const filterChannel = channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery) @@ -467,14 +492,18 @@ const allChannels = createSelector( const filteredPendingOpenChannels = pendingOpenChannels.filter(filterPendingChannel) const filteredPendingClosedChannels = pendingClosedChannels.filter(filterPendingChannel) const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel) + const filteredWaitingCloseChannels = waitingCloseChannels.filter(filterPendingChannel) + return [ ...filteredActiveChannels, ...filteredPendingOpenChannels, ...filteredPendingClosedChannels, ...filteredPendingForcedClosedChannels, - ...filteredNonActiveChannels + ...filteredNonActiveChannels, + ...filteredWaitingCloseChannels ] + } ) @@ -508,6 +537,7 @@ export const currentChannels = createSelector( } } + const channelArray = filteredArray(channelFilter.key) return channelArray.filter(channel => (Object.prototype.hasOwnProperty.call(channel, 'channel') ? @@ -529,7 +559,8 @@ const initialState = { total_limbo_balance: '', pending_open_channels: [], pending_closing_channels: [], - pending_force_closing_channels: [] + pending_force_closing_channels: [], + waiting_close_channels: [] }, channel: null, channelForm: { From a42b1a04e620fe7a8aa570ce7db26db9864f5da4 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Sat, 5 May 2018 00:30:05 -0500 Subject: [PATCH 2/2] fix(lint/tests): fix lint/tests and remove hard coded data --- app/reducers/channels.js | 27 +------------------ .../__snapshots__/channels.spec.js.snap | 4 +++ 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/app/reducers/channels.js b/app/reducers/channels.js index f539c966..cd85d50d 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -337,30 +337,7 @@ const ACTION_HANDLERS = { [GET_CHANNELS]: state => ({ ...state, channelsLoading: true }), [RECEIVE_CHANNELS]: (state, { 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: [] - }, + ...state, channelsLoading: false, channels, pendingChannels } ), @@ -494,7 +471,6 @@ const allChannels = createSelector( const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel) const filteredWaitingCloseChannels = waitingCloseChannels.filter(filterPendingChannel) - return [ ...filteredActiveChannels, ...filteredPendingOpenChannels, @@ -503,7 +479,6 @@ const allChannels = createSelector( ...filteredNonActiveChannels, ...filteredWaitingCloseChannels ] - } ) diff --git a/test/reducers/__snapshots__/channels.spec.js.snap b/test/reducers/__snapshots__/channels.spec.js.snap index d1e95f6b..cb398edc 100644 --- a/test/reducers/__snapshots__/channels.spec.js.snap +++ b/test/reducers/__snapshots__/channels.spec.js.snap @@ -51,6 +51,7 @@ Object { "pending_force_closing_channels": Array [], "pending_open_channels": Array [], "total_limbo_balance": "", + "waiting_close_channels": Array [], }, "searchQuery": "", "selectedChannel": null, @@ -114,6 +115,7 @@ Object { "pending_force_closing_channels": Array [], "pending_open_channels": Array [], "total_limbo_balance": "", + "waiting_close_channels": Array [], }, "searchQuery": "", "selectedChannel": null, @@ -241,6 +243,7 @@ Object { "pending_force_closing_channels": Array [], "pending_open_channels": Array [], "total_limbo_balance": "", + "waiting_close_channels": Array [], }, "searchQuery": "", "selectedChannel": null, @@ -304,6 +307,7 @@ Object { "pending_force_closing_channels": Array [], "pending_open_channels": Array [], "total_limbo_balance": "", + "waiting_close_channels": Array [], }, "searchQuery": "", "selectedChannel": null,