bring in 'blocked' code from lbry-redux take 2

This commit is contained in:
Sean Yesmunt 2020-07-15 09:50:08 -04:00
parent 9c9530c6f3
commit 69cfcd81e9
23 changed files with 97 additions and 55 deletions

View file

@ -136,7 +136,7 @@
"imagesloaded": "^4.1.4", "imagesloaded": "^4.1.4",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#a1673ebfa933c0e921a23a1877d22e21c2bff8f9", "lbry-redux": "lbryio/lbry-redux#0ec72d09d438c60d25cc56d256df971a9d3b2c0a",
"lbryinc": "lbryio/lbryinc#cff5dd60934c4c6080e135f47ebbece1548c658c", "lbryinc": "lbryio/lbryinc#cff5dd60934c4c6080e135f47ebbece1548c658c",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectBlockedChannels } from 'lbry-redux'; import { selectBlockedChannels } from 'redux/selectors/blocked';
import { doChannelUnsubscribe } from 'redux/actions/subscriptions'; import { doChannelUnsubscribe } from 'redux/actions/subscriptions';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
import AbandonedChannelPreview from './view'; import AbandonedChannelPreview from './view';

View file

@ -1,12 +1,8 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import { makeSelectClaimIsMine, makeSelectShortUrlForUri, makeSelectPermanentUrlForUri } from 'lbry-redux';
selectChannelIsBlocked, import { selectChannelIsBlocked } from 'redux/selectors/blocked';
doToggleBlockChannel,
makeSelectClaimIsMine,
makeSelectShortUrlForUri,
makeSelectPermanentUrlForUri,
} from 'lbry-redux';
import { doToast } from 'redux/actions/notifications'; import { doToast } from 'redux/actions/notifications';
import { doToggleBlockChannel } from 'redux/actions/blocked';
import BlockButton from './view'; import BlockButton from './view';
const select = (state, props) => ({ const select = (state, props) => ({

View file

@ -6,9 +6,9 @@ import {
makeSelectFetchingChannelClaims, makeSelectFetchingChannelClaims,
makeSelectClaimIsMine, makeSelectClaimIsMine,
makeSelectTotalPagesInChannelSearch, makeSelectTotalPagesInChannelSearch,
selectChannelIsBlocked,
makeSelectClaimForUri, makeSelectClaimForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectChannelIsBlocked } from 'redux/selectors/blocked';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';

View file

@ -4,10 +4,10 @@ import {
selectClaimSearchByQuery, selectClaimSearchByQuery,
selectClaimSearchByQueryLastPageReached, selectClaimSearchByQueryLastPageReached,
selectFetchingClaimSearch, selectFetchingClaimSearch,
selectBlockedChannels,
SETTINGS, SETTINGS,
selectFollowedTags, selectFollowedTags,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlockedChannels } from 'redux/selectors/blocked';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';

View file

@ -7,13 +7,12 @@ import {
makeSelectClaimIsPending, makeSelectClaimIsPending,
makeSelectCoverForUri, makeSelectCoverForUri,
makeSelectClaimIsNsfw, makeSelectClaimIsNsfw,
selectBlockedChannels,
selectChannelIsBlocked,
doFileGet, doFileGet,
makeSelectReflectingClaimForUri, makeSelectReflectingClaimForUri,
makeSelectClaimWasPurchased, makeSelectClaimWasPurchased,
makeSelectStreamingUrlForUri, makeSelectStreamingUrlForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlockedChannels, selectChannelIsBlocked } from 'redux/selectors/blocked';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import { makeSelectHasVisitedUri } from 'redux/selectors/content'; import { makeSelectHasVisitedUri } from 'redux/selectors/content';

View file

@ -7,9 +7,9 @@ import {
makeSelectTitleForUri, makeSelectTitleForUri,
doFileGet, doFileGet,
makeSelectChannelForClaimUri, makeSelectChannelForClaimUri,
selectBlockedChannels,
makeSelectClaimIsNsfw, makeSelectClaimIsNsfw,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlockedChannels } from 'redux/selectors/blocked';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import ClaimPreviewTile from './view'; import ClaimPreviewTile from './view';
@ -32,7 +32,4 @@ const perform = dispatch => ({
getFile: uri => dispatch(doFileGet(uri, false)), getFile: uri => dispatch(doFileGet(uri, false)),
}); });
export default connect( export default connect(select, perform)(ClaimPreviewTile);
select,
perform
)(ClaimPreviewTile);

View file

@ -1,11 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import { doClaimSearch, selectClaimSearchByQuery, selectFetchingClaimSearch, SETTINGS } from 'lbry-redux';
doClaimSearch, import { selectBlockedChannels } from 'redux/selectors/blocked';
selectClaimSearchByQuery,
selectFetchingClaimSearch,
selectBlockedChannels,
SETTINGS,
} from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';

View file

@ -5,10 +5,10 @@ import {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectThumbnailForUri, makeSelectThumbnailForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
selectChannelIsBlocked,
doCommentUpdate, // doEditComment would be a more fitting name doCommentUpdate, // doEditComment would be a more fitting name
doCommentAbandon, doCommentAbandon,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectChannelIsBlocked } from 'redux/selectors/blocked';
import Comment from './view'; import Comment from './view';
const select = (state, props) => ({ const select = (state, props) => ({

View file

@ -246,3 +246,6 @@ export const COMMENT_UPDATE_FAILED = 'COMMENT_UPDATE_FAILED';
export const COMMENT_HIDE_STARTED = 'COMMENT_HIDE_STARTED'; export const COMMENT_HIDE_STARTED = 'COMMENT_HIDE_STARTED';
export const COMMENT_HIDE_COMPLETED = 'COMMENT_HIDE_COMPLETED'; export const COMMENT_HIDE_COMPLETED = 'COMMENT_HIDE_COMPLETED';
export const COMMENT_HIDE_FAILED = 'COMMENT_HIDE_FAILED'; export const COMMENT_HIDE_FAILED = 'COMMENT_HIDE_FAILED';
// Blocked Channels
export const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';

View file

@ -1,7 +1,8 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideModal } from 'redux/actions/app';
import { doToggleBlockChannel } from 'redux/actions/blocked';
import { selectBlockedChannels } from 'redux/selectors/blocked';
import ModalRemoveBlocked from './view'; import ModalRemoveBlocked from './view';
import { doToggleBlockChannel, selectBlockedChannels } from 'lbry-redux';
const select = (state, props) => ({ const select = (state, props) => ({
blockedChannels: selectBlockedChannels(state), blockedChannels: selectBlockedChannels(state),

View file

@ -6,9 +6,9 @@ import {
makeSelectCoverForUri, makeSelectCoverForUri,
selectCurrentChannelPage, selectCurrentChannelPage,
makeSelectClaimForUri, makeSelectClaimForUri,
selectChannelIsBlocked,
makeSelectClaimIsPending, makeSelectClaimIsPending,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectChannelIsBlocked } from 'redux/selectors/blocked';
import { selectBlackListedOutpoints, doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc'; import { selectBlackListedOutpoints, doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectFollowedTags, selectBlockedChannels } from 'lbry-redux'; import { selectFollowedTags } from 'lbry-redux';
import { selectBlockedChannels } from 'redux/selectors/blocked';
import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { selectSubscriptions } from 'redux/selectors/subscriptions';
import ChannelsFollowingManagePage from './view'; import ChannelsFollowingManagePage from './view';

View file

@ -1,12 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectBlockedChannels } from 'lbry-redux'; import { selectBlockedChannels } from 'redux/selectors/blocked';
import ListBlocked from './view'; import ListBlocked from './view';
const select = state => ({ const select = state => ({
uris: selectBlockedChannels(state), uris: selectBlockedChannels(state),
}); });
export default connect( export default connect(select, null)(ListBlocked);
select,
null
)(ListBlocked);

View file

@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import ClaimList from 'component/claimList'; import ClaimList from 'component/claimList';
import Page from 'component/page'; import Page from 'component/page';
import Card from 'component/common/card';
type Props = { type Props = {
uris: Array<string>, uris: Array<string>,
@ -13,13 +14,10 @@ function ListBlocked(props: Props) {
return ( return (
<Page> <Page>
{uris && uris.length ? ( {uris && uris.length ? (
<ClaimList <Card
header={<h1>{__('Your Blocked Channels')}</h1>} isBodyList
persistedStorageKey="block-list-published" title={__('Your Blocked Channels')}
uris={uris} body={<ClaimList isCardBody uris={uris} showUnresolvedClaims showHiddenByUser />}
defaultSort
showUnresolvedClaims
showHiddenByUser
/> />
) : ( ) : (
<div className="main--empty"> <div className="main--empty">

View file

@ -22,7 +22,8 @@ import {
selectFfmpegStatus, selectFfmpegStatus,
selectFindingFFmpeg, selectFindingFFmpeg,
} from 'redux/selectors/settings'; } from 'redux/selectors/settings';
import { doWalletStatus, selectWalletIsEncrypted, selectBlockedChannelsCount, SETTINGS } from 'lbry-redux'; import { doWalletStatus, selectWalletIsEncrypted, SETTINGS } from 'lbry-redux';
import { selectBlockedChannelsCount } from 'redux/selectors/blocked';
import SettingsPage from './view'; import SettingsPage from './view';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';

View file

@ -1,14 +1,6 @@
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import { connectRouter } from 'connected-react-router'; import { connectRouter } from 'connected-react-router';
import { import { claimsReducer, fileInfoReducer, searchReducer, walletReducer, tagsReducer, publishReducer } from 'lbry-redux';
claimsReducer,
fileInfoReducer,
searchReducer,
walletReducer,
tagsReducer,
blockedReducer,
publishReducer,
} from 'lbry-redux';
import { import {
costInfoReducer, costInfoReducer,
blacklistReducer, blacklistReducer,
@ -26,6 +18,7 @@ import notificationsReducer from 'redux/reducers/notifications';
import rewardsReducer from 'redux/reducers/rewards'; import rewardsReducer from 'redux/reducers/rewards';
import userReducer from 'redux/reducers/user'; import userReducer from 'redux/reducers/user';
import commentsReducer from 'redux/reducers/comments'; import commentsReducer from 'redux/reducers/comments';
import blockedReducer from 'redux/reducers/blocked';
export default history => export default history =>
combineReducers({ combineReducers({

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,39 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-redux';
import { handleActions } from 'util/redux-utils';
const defaultState: BlocklistState = {
blockedChannels: [],
};
export default 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,
};
},
[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE]: (
state: BlocklistState,
action: { data: { blocked: ?Array<string> } }
) => {
const { blocked } = action.data;
return {
...state,
blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels,
};
},
},
defaultState
);

View file

@ -0,0 +1,13 @@
// @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

@ -9,12 +9,12 @@ import {
makeSelectRecommendedContentForUri, makeSelectRecommendedContentForUri,
makeSelectMediaTypeForUri, makeSelectMediaTypeForUri,
selectBalance, selectBalance,
selectBlockedChannels,
parseURI, parseURI,
buildURI, buildURI,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectFileNameForUri, makeSelectFileNameForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectBlockedChannels } from 'redux/selectors/blocked';
import { selectAllCostInfoByUri, makeSelectCostInfoForUri } from 'lbryinc'; import { selectAllCostInfoByUri, makeSelectCostInfoForUri } from 'lbryinc';
import { selectShowMatureContent } from 'redux/selectors/settings'; import { selectShowMatureContent } from 'redux/selectors/settings';
import * as RENDER_MODES from 'constants/file_render_modes'; import * as RENDER_MODES from 'constants/file_render_modes';

View file

@ -117,8 +117,8 @@ history = createBrowserHistory();
const triggerSharedStateActions = [ const triggerSharedStateActions = [
ACTIONS.CHANNEL_SUBSCRIBE, ACTIONS.CHANNEL_SUBSCRIBE,
ACTIONS.CHANNEL_UNSUBSCRIBE, ACTIONS.CHANNEL_UNSUBSCRIBE,
ACTIONS.TOGGLE_BLOCK_CHANNEL,
LBRY_REDUX_ACTIONS.TOGGLE_TAG_FOLLOW, LBRY_REDUX_ACTIONS.TOGGLE_TAG_FOLLOW,
LBRY_REDUX_ACTIONS.TOGGLE_BLOCK_CHANNEL,
LBRY_REDUX_ACTIONS.CREATE_CHANNEL_COMPLETED, LBRY_REDUX_ACTIONS.CREATE_CHANNEL_COMPLETED,
// Disabled until we can overwrite preferences // Disabled until we can overwrite preferences
// LBRY_REDUX_ACTIONS.SHARED_PREFERENCE_SET, // LBRY_REDUX_ACTIONS.SHARED_PREFERENCE_SET,

View file

@ -6383,9 +6383,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2" yargs "^13.2.2"
zstd-codec "^0.1.1" zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#a1673ebfa933c0e921a23a1877d22e21c2bff8f9: lbry-redux@lbryio/lbry-redux#0ec72d09d438c60d25cc56d256df971a9d3b2c0a:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/a1673ebfa933c0e921a23a1877d22e21c2bff8f9" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/0ec72d09d438c60d25cc56d256df971a9d3b2c0a"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"