supports user channel block uri list

This commit is contained in:
jessop 2019-07-26 10:45:14 -04:00
parent 250f5003d9
commit 8406e8c25e
8 changed files with 98 additions and 19 deletions

10
dist/flow-typed/Blocklist.js vendored Normal file
View file

@ -0,0 +1,10 @@
declare type BlocklistState = {
blockedChannels: Array<string>
};
declare type BlocklistAction = {
type: string,
data: {
uri: string,
},
};

10
flow-typed/Blocklist.js vendored Normal file
View file

@ -0,0 +1,10 @@
declare type BlocklistState = {
blockedChannels: Array<string>
};
declare type BlocklistAction = {
type: string,
data: {
uri: string,
},
};

View file

@ -235,3 +235,5 @@ export const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED';
export const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
export const TAG_ADD = 'TAG_ADD';
export const TAG_DELETE = 'TAG_DELETE';
// Blocked Channels
export const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';

View file

@ -111,6 +111,8 @@ export { doToggleTagFollow, doAddTag, doDeleteTag } from 'redux/actions/tags';
export { doCommentList, doCommentCreate } from 'redux/actions/comments';
export { doToggleBlockChannel } from 'redux/actions/blocked';
// utils
export { batchActions } from 'util/batch-actions';
export { parseQueryParams, toQueryString } from 'util/query-params';
@ -127,6 +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 { walletReducer } from 'redux/reducers/wallet';
// selectors
@ -269,3 +272,5 @@ export {
} from 'redux/selectors/wallet';
export { selectFollowedTags, selectUnfollowedTags } from 'redux/selectors/tags';
export { selectBlockedChannels, selectChannelIsBlocked } from 'redux/selectors/blocked';

View file

@ -0,0 +1,9 @@
// @flow
import * as ACTIONS from 'constants/action_types';
export const doToggleBlockChannel = (uri: string) => ({
type: ACTIONS.TOGGLE_BLOCK_CHANNEL,
data: {
uri,
},
});

View file

@ -0,0 +1,29 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
const defaultState: BlocklistState = {
blockedChannels: [],
}
export const blockChannelReducer = handleActions(
{
[ACTIONS.TOGGLE_BLOCK_CHANNEL]: (state: BlocklistState, action: BlocklistAction): BlocklistState => {
const { blockedChannels } = state;
const { uri } = action.data;
console.log('test', uri)
let newBlockedChannels = blockedChannels.slice();
if (newBlockedChannels.includes(uri)) {
newBlockedChannels = newBlockedChannels.filter(id => id !== uri);
} else {
newBlockedChannels.push(uri);
}
return {
blockedChannels: newBlockedChannels,
};
},
},
defaultState
);

View file

@ -0,0 +1,14 @@
// @flow
import { createSelector } from 'reselect';
const selectState = (state: { blockedChannels: BlocklistState }) => state.blockedChannels || {};
export const selectBlockedChannels = createSelector(
selectState,
(state: BlocklistState) => state
);
export const selectChannelIsBlocked = (uri: string) => createSelector(
selectState,
(state: BlocklistState) => { return state.blockedChannels.includes(uri) }
);

View file

@ -190,31 +190,31 @@ export const selectSearchDownloadUris = query =>
return downloadResultsFromQuery.length
? downloadResultsFromQuery.map(fileInfo => {
const {
channel_name: channelName,
claim_id: claimId,
claim_name: claimName,
} = fileInfo;
const {
channel_name: channelName,
claim_id: claimId,
claim_name: claimName,
} = fileInfo;
const uriParams = {};
const uriParams = {};
if (channelName) {
const claim = claimsById[claimId];
if (claim && claim.signing_channel) {
uriParams.claimId = claim.signing_channel.claim_id;
} else {
uriParams.claimId = claimId;
}
uriParams.channelName = channelName;
uriParams.contentName = claimName;
if (channelName) {
const claim = claimsById[claimId];
if (claim && claim.signing_channel) {
uriParams.claimId = claim.signing_channel.claim_id;
} else {
uriParams.claimId = claimId;
uriParams.claimName = claimName;
}
uriParams.channelName = channelName;
uriParams.contentName = claimName;
} else {
uriParams.claimId = claimId;
uriParams.claimName = claimName;
}
const uri = buildURI(uriParams);
return uri;
})
const uri = buildURI(uriParams);
return uri;
})
: null;
}
);