2020-07-15 15:50:08 +02:00
|
|
|
// @flow
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
const selectState = (state: { blocked: BlocklistState }) => state.blocked || {};
|
|
|
|
|
2020-08-24 19:56:26 +02:00
|
|
|
export const selectBlockedChannels = createSelector(selectState, (state: BlocklistState) => {
|
|
|
|
return state.blockedChannels.filter(e => typeof e === 'string');
|
|
|
|
});
|
2020-07-15 15:50:08 +02:00
|
|
|
|
|
|
|
export const selectBlockedChannelsCount = createSelector(selectBlockedChannels, (state: Array<string>) => state.length);
|
|
|
|
|
2020-08-24 19:35:21 +02:00
|
|
|
export const selectBlockedChannelsObj = createSelector(selectState, (state: BlocklistState) => {
|
|
|
|
return state.blockedChannels.reduce((acc: any, val: any) => {
|
|
|
|
const outpoint = `${val.txid}:${String(val.nout)}`;
|
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[outpoint]: 1,
|
|
|
|
};
|
|
|
|
}, {});
|
|
|
|
});
|
|
|
|
|
2020-07-15 15:50:08 +02:00
|
|
|
export const selectChannelIsBlocked = (uri: string) =>
|
|
|
|
createSelector(selectBlockedChannels, (state: Array<string>) => {
|
|
|
|
return state.includes(uri);
|
|
|
|
});
|