2020-07-15 15:50:08 +02:00
|
|
|
// @flow
|
|
|
|
import { createSelector } from 'reselect';
|
2021-09-29 10:26:44 +02:00
|
|
|
import { splitBySeparator } from 'lbry-redux';
|
2020-07-15 15:50:08 +02:00
|
|
|
|
|
|
|
const selectState = (state: { blocked: BlocklistState }) => state.blocked || {};
|
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectMutedChannels = createSelector(selectState, (state: BlocklistState) => {
|
|
|
|
return state.blockedChannels.filter((e) => typeof e === 'string');
|
2020-08-24 19:56:26 +02:00
|
|
|
});
|
2020-07-15 15:50:08 +02:00
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const makeSelectChannelIsMuted = (uri: string) =>
|
|
|
|
createSelector(selectMutedChannels, (state: Array<string>) => {
|
2020-07-15 15:50:08 +02:00
|
|
|
return state.includes(uri);
|
|
|
|
});
|
2021-09-29 10:26:44 +02:00
|
|
|
|
|
|
|
export const selectMutedAndBlockedChannelIds = createSelector(
|
|
|
|
selectState,
|
|
|
|
(state) => state.comments,
|
|
|
|
(state, commentsState) => {
|
|
|
|
const mutedUris = state.blockedChannels;
|
|
|
|
const blockedUris = commentsState.moderationBlockList;
|
|
|
|
return Array.from(
|
|
|
|
new Set((mutedUris || []).concat(blockedUris || []).map((uri) => splitBySeparator(uri)[1]))
|
|
|
|
).sort();
|
|
|
|
}
|
|
|
|
);
|