Merge pull request #175 from lbryio/channelFilterMM

Channel filter mm
This commit is contained in:
Sean Yesmunt 2019-08-02 13:54:59 -04:00 committed by GitHub
commit 30c26b6cdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 168 additions and 22 deletions

59
dist/bundle.es.js vendored
View file

@ -260,6 +260,8 @@ const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED';
const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
const TAG_ADD = 'TAG_ADD';
const TAG_DELETE = 'TAG_DELETE';
// Blocked Channels
const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
var action_types = /*#__PURE__*/Object.freeze({
WINDOW_FOCUSED: WINDOW_FOCUSED,
@ -466,7 +468,8 @@ var action_types = /*#__PURE__*/Object.freeze({
FETCH_COST_INFO_FAILED: FETCH_COST_INFO_FAILED,
TOGGLE_TAG_FOLLOW: TOGGLE_TAG_FOLLOW,
TAG_ADD: TAG_ADD,
TAG_DELETE: TAG_DELETE
TAG_DELETE: TAG_DELETE,
TOGGLE_BLOCK_CHANNEL: TOGGLE_BLOCK_CHANNEL
});
const CC_LICENSES = [{
@ -3432,6 +3435,15 @@ function doCommentCreate(comment = '', claim_id = '', channel, parent_id) {
};
}
//
const doToggleBlockChannel = uri => ({
type: TOGGLE_BLOCK_CHANNEL,
data: {
uri
}
});
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers = {};
@ -4353,6 +4365,30 @@ const tagsReducer = handleActions({
}
}, defaultState$8);
//
const defaultState$9 = {
blockedChannels: []
};
const blockedReducer = handleActions({
[TOGGLE_BLOCK_CHANNEL]: (state, action) => {
const { blockedChannels } = state;
const { uri } = action.data;
let newBlockedChannels = blockedChannels.slice();
if (newBlockedChannels.includes(uri)) {
newBlockedChannels = newBlockedChannels.filter(id => id !== uri);
} else {
newBlockedChannels.push(uri);
}
return {
blockedChannels: newBlockedChannels
};
}
}, defaultState$9);
var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const buildDraftTransaction = () => ({
@ -4364,7 +4400,7 @@ const buildDraftTransaction = () => ({
// See details in https://github.com/lbryio/lbry/issues/1307
const defaultState$9 = {
const defaultState$a = {
balance: undefined,
totalBalance: undefined,
latestBlock: undefined,
@ -4607,7 +4643,7 @@ const walletReducer = handleActions({
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$e({}, state, {
latestBlock: action.data
})
}, defaultState$9);
}, defaultState$a);
const selectState$6 = state => state.content || {};
@ -4695,6 +4731,18 @@ const selectUnfollowedTags = reselect.createSelector(selectKnownTagsByName, sele
return tagsToReturn;
});
//
const selectState$a = state => state.blocked || {};
const selectBlockedChannels = reselect.createSelector(selectState$a, state => state.blockedChannels);
const selectBlockedChannelsCount = reselect.createSelector(selectBlockedChannels, state => state.length);
const selectChannelIsBlocked = uri => reselect.createSelector(selectBlockedChannels, state => {
return state.includes(uri);
});
exports.ACTIONS = action_types;
exports.CLAIM_VALUES = claim;
exports.DEFAULT_FOLLOWED_TAGS = DEFAULT_FOLLOWED_TAGS;
@ -4710,6 +4758,7 @@ exports.SORT_OPTIONS = sort_options;
exports.THUMBNAIL_STATUSES = thumbnail_upload_statuses;
exports.TRANSACTIONS = transaction_types;
exports.batchActions = batchActions;
exports.blockedReducer = blockedReducer;
exports.buildURI = buildURI;
exports.claimsReducer = claimsReducer;
exports.commentReducer = commentReducer;
@ -4757,6 +4806,7 @@ exports.doSetDraftTransactionAmount = doSetDraftTransactionAmount;
exports.doSetFileListSort = doSetFileListSort;
exports.doSetTransactionListFilter = doSetTransactionListFilter;
exports.doToast = doToast;
exports.doToggleBlockChannel = doToggleBlockChannel;
exports.doToggleTagFollow = doToggleTagFollow;
exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe;
exports.doUpdateBalance = doUpdateBalance;
@ -4828,8 +4878,11 @@ exports.selectAllClaimsByChannel = selectAllClaimsByChannel;
exports.selectAllFetchingChannelClaims = selectAllFetchingChannelClaims;
exports.selectAllMyClaimsByOutpoint = selectAllMyClaimsByOutpoint;
exports.selectBalance = selectBalance;
exports.selectBlockedChannels = selectBlockedChannels;
exports.selectBlockedChannelsCount = selectBlockedChannelsCount;
exports.selectBlocks = selectBlocks;
exports.selectChannelClaimCounts = selectChannelClaimCounts;
exports.selectChannelIsBlocked = selectChannelIsBlocked;
exports.selectClaimSearchByQuery = selectClaimSearchByQuery;
exports.selectClaimsById = selectClaimsById;
exports.selectClaimsByUri = selectClaimsByUri;

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 { blockedReducer } from 'redux/reducers/blocked';
export { walletReducer } from 'redux/reducers/wallet';
// selectors
@ -269,3 +272,9 @@ export {
} from 'redux/selectors/wallet';
export { selectFollowedTags, selectUnfollowedTags } from 'redux/selectors/tags';
export {
selectBlockedChannels,
selectChannelIsBlocked,
selectBlockedChannelsCount,
} 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,31 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
const defaultState: BlocklistState = {
blockedChannels: [],
};
export const blockedReducer = handleActions(
{
[ACTIONS.TOGGLE_BLOCK_CHANNEL]: (
state: BlocklistState,
action: BlocklistAction
): BlocklistState => {
const { blockedChannels } = state;
const { uri } = action.data;
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,22 @@
// @flow
import { createSelector } from 'reselect';
const selectState = (state: { blocked: BlocklistState }) => state.blocked || {};
export const selectBlockedChannels = createSelector(
selectState,
(state: BlocklistState) => state.blockedChannels
);
export const selectBlockedChannelsCount = createSelector(
selectBlockedChannels,
(state: Array<string>) => state.length
);
export const selectChannelIsBlocked = (uri: string) =>
createSelector(
selectBlockedChannels,
(state: Array<string>) => {
return state.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;
}
);