lbry-desktop/ui/component/channelContent/index.js

49 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-05-07 04:35:04 +02:00
import { connect } from 'react-redux';
import { PAGE_SIZE } from 'constants/claim';
import {
2019-07-22 02:13:42 +02:00
makeSelectClaimsInChannelForPage,
2019-05-07 04:35:04 +02:00
makeSelectFetchingChannelClaims,
selectClaimIsMine,
makeSelectTotalPagesInChannelSearch,
selectClaimForUri,
} from 'redux/selectors/claims';
import { doResolveUris } from 'redux/actions/claims';
import * as SETTINGS from 'constants/settings';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
2019-07-22 02:13:42 +02:00
import { withRouter } from 'react-router';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import { doFetchActiveLivestream } from 'redux/actions/livestream';
import { selectActiveLivestreamForChannel, selectActiveLivestreamInitialized } from 'redux/selectors/livestream';
import { getChannelIdFromClaim } from 'util/claim';
import ChannelContent from './view';
2019-05-07 04:35:04 +02:00
2019-07-22 02:13:42 +02:00
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const page = urlParams.get('page') || 0;
const claim = props.uri && selectClaimForUri(state, props.uri);
const channelClaimId = getChannelIdFromClaim(claim);
2019-07-22 02:13:42 +02:00
return {
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
2019-07-22 02:13:42 +02:00
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
channelIsMine: selectClaimIsMine(state, claim),
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
claim,
2020-03-26 22:47:07 +01:00
isAuthenticated: selectUserVerifiedEmail(state),
2021-03-31 22:55:26 +02:00
showMature: selectShowMatureContent(state),
tileLayout: selectClientSetting(state, SETTINGS.TILE_LAYOUT),
activeLivestreamForChannel: selectActiveLivestreamForChannel(state, channelClaimId),
activeLivestreamInitialized: selectActiveLivestreamInitialized(state),
2019-07-22 02:13:42 +02:00
};
};
2019-05-07 04:35:04 +02:00
const perform = (dispatch) => ({
doResolveUris: (uris, returnCachedUris) => dispatch(doResolveUris(uris, returnCachedUris)),
doFetchActiveLivestream: (channelID) => dispatch(doFetchActiveLivestream(channelID)),
});
export default withRouter(connect(select, perform)(ChannelContent));