supports user channel block uri list
This commit is contained in:
parent
250f5003d9
commit
8406e8c25e
8 changed files with 98 additions and 19 deletions
10
dist/flow-typed/Blocklist.js
vendored
Normal file
10
dist/flow-typed/Blocklist.js
vendored
Normal 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
10
flow-typed/Blocklist.js
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
declare type BlocklistState = {
|
||||||
|
blockedChannels: Array<string>
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type BlocklistAction = {
|
||||||
|
type: string,
|
||||||
|
data: {
|
||||||
|
uri: string,
|
||||||
|
},
|
||||||
|
};
|
|
@ -235,3 +235,5 @@ export const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED';
|
||||||
export const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
|
export const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
|
||||||
export const TAG_ADD = 'TAG_ADD';
|
export const TAG_ADD = 'TAG_ADD';
|
||||||
export const TAG_DELETE = 'TAG_DELETE';
|
export const TAG_DELETE = 'TAG_DELETE';
|
||||||
|
// Blocked Channels
|
||||||
|
export const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
|
||||||
|
|
|
@ -111,6 +111,8 @@ export { doToggleTagFollow, doAddTag, doDeleteTag } from 'redux/actions/tags';
|
||||||
|
|
||||||
export { doCommentList, doCommentCreate } from 'redux/actions/comments';
|
export { doCommentList, doCommentCreate } from 'redux/actions/comments';
|
||||||
|
|
||||||
|
export { doToggleBlockChannel } from 'redux/actions/blocked';
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
export { batchActions } from 'util/batch-actions';
|
export { batchActions } from 'util/batch-actions';
|
||||||
export { parseQueryParams, toQueryString } from 'util/query-params';
|
export { parseQueryParams, toQueryString } from 'util/query-params';
|
||||||
|
@ -127,6 +129,7 @@ export { notificationsReducer } from 'redux/reducers/notifications';
|
||||||
export { publishReducer } from 'redux/reducers/publish';
|
export { publishReducer } from 'redux/reducers/publish';
|
||||||
export { searchReducer } from 'redux/reducers/search';
|
export { searchReducer } from 'redux/reducers/search';
|
||||||
export { tagsReducer } from 'redux/reducers/tags';
|
export { tagsReducer } from 'redux/reducers/tags';
|
||||||
|
export { blockChannelReducer } from 'redux/reducers/blocked';
|
||||||
export { walletReducer } from 'redux/reducers/wallet';
|
export { walletReducer } from 'redux/reducers/wallet';
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
|
@ -269,3 +272,5 @@ export {
|
||||||
} from 'redux/selectors/wallet';
|
} from 'redux/selectors/wallet';
|
||||||
|
|
||||||
export { selectFollowedTags, selectUnfollowedTags } from 'redux/selectors/tags';
|
export { selectFollowedTags, selectUnfollowedTags } from 'redux/selectors/tags';
|
||||||
|
|
||||||
|
export { selectBlockedChannels, selectChannelIsBlocked } from 'redux/selectors/blocked';
|
||||||
|
|
9
src/redux/actions/blocked.js
Normal file
9
src/redux/actions/blocked.js
Normal 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,
|
||||||
|
},
|
||||||
|
});
|
29
src/redux/reducers/blocked.js
Normal file
29
src/redux/reducers/blocked.js
Normal 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
|
||||||
|
);
|
14
src/redux/selectors/blocked.js
Normal file
14
src/redux/selectors/blocked.js
Normal 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) }
|
||||||
|
);
|
Loading…
Reference in a new issue