changes after review

This commit is contained in:
jessop 2019-08-02 10:56:32 -04:00
parent e25af99fb8
commit 8f12baa88f
4 changed files with 28 additions and 18 deletions

12
dist/bundle.es.js vendored
View file

@ -4371,7 +4371,7 @@ const defaultState$9 = {
blockedChannels: []
};
const blockChannelReducer = handleActions({
const blockedReducer = handleActions({
[TOGGLE_BLOCK_CHANNEL]: (state, action) => {
const { blockedChannels } = state;
const { uri } = action.data;
@ -4733,14 +4733,14 @@ const selectUnfollowedTags = reselect.createSelector(selectKnownTagsByName, sele
//
const selectState$a = state => state.blockedChannels || {};
const selectState$a = state => state.blocked || {};
const selectBlockedChannels = reselect.createSelector(selectState$a, state => state.blockedChannels);
const selectBlockedChannelsCount = reselect.createSelector(selectState$a, state => state.blockedChannels.length);
const selectBlockedChannelsCount = reselect.createSelector(selectBlockedChannels, state => state.length);
const selectChannelIsBlocked = uri => reselect.createSelector(selectState$a, state => {
return state.blockedChannels.includes(uri);
const selectChannelIsBlocked = uri => reselect.createSelector(selectBlockedChannels, state => {
return state.includes(uri);
});
exports.ACTIONS = action_types;
@ -4758,7 +4758,7 @@ exports.SORT_OPTIONS = sort_options;
exports.THUMBNAIL_STATUSES = thumbnail_upload_statuses;
exports.TRANSACTIONS = transaction_types;
exports.batchActions = batchActions;
exports.blockChannelReducer = blockChannelReducer;
exports.blockedReducer = blockedReducer;
exports.buildURI = buildURI;
exports.claimsReducer = claimsReducer;
exports.commentReducer = commentReducer;

View file

@ -129,7 +129,7 @@ export { notificationsReducer } from 'redux/reducers/notifications';
export { publishReducer } from 'redux/reducers/publish';
export { searchReducer } from 'redux/reducers/search';
export { tagsReducer } from 'redux/reducers/tags';
export { blockChannelReducer } from 'redux/reducers/blocked';
export { blockedReducer } from 'redux/reducers/blocked';
export { walletReducer } from 'redux/reducers/wallet';
// selectors
@ -273,4 +273,8 @@ export {
export { selectFollowedTags, selectUnfollowedTags } from 'redux/selectors/tags';
export { selectBlockedChannels, selectChannelIsBlocked, selectBlockedChannelsCount } from 'redux/selectors/blocked';
export {
selectBlockedChannels,
selectChannelIsBlocked,
selectBlockedChannelsCount,
} from 'redux/selectors/blocked';

View file

@ -4,11 +4,14 @@ import { handleActions } from 'util/redux-utils';
const defaultState: BlocklistState = {
blockedChannels: [],
}
};
export const blockChannelReducer = handleActions(
export const blockedReducer = handleActions(
{
[ACTIONS.TOGGLE_BLOCK_CHANNEL]: (state: BlocklistState, action: BlocklistAction): BlocklistState => {
[ACTIONS.TOGGLE_BLOCK_CHANNEL]: (
state: BlocklistState,
action: BlocklistAction
): BlocklistState => {
const { blockedChannels } = state;
const { uri } = action.data;
let newBlockedChannels = blockedChannels.slice();

View file

@ -1,7 +1,7 @@
// @flow
import { createSelector } from 'reselect';
const selectState = (state: { blockedChannels: BlocklistState }) => state.blockedChannels || {};
const selectState = (state: { blocked: BlocklistState }) => state.blocked || {};
export const selectBlockedChannels = createSelector(
selectState,
@ -9,11 +9,14 @@ export const selectBlockedChannels = createSelector(
);
export const selectBlockedChannelsCount = createSelector(
selectState,
(state: BlocklistState) => state.blockedChannels.length
selectBlockedChannels,
(state: Array<string>) => state.length
);
export const selectChannelIsBlocked = (uri: string) => createSelector(
selectState,
(state: BlocklistState) => { return state.blockedChannels.includes(uri) }
);
export const selectChannelIsBlocked = (uri: string) =>
createSelector(
selectBlockedChannels,
(state: Array<string>) => {
return state.includes(uri);
}
);