2019-05-06 22:35:04 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { PAGE_SIZE } from 'constants/claim';
|
|
|
|
import {
|
2019-07-21 20:13:42 -04:00
|
|
|
makeSelectClaimsInChannelForPage,
|
2019-05-06 22:35:04 -04:00
|
|
|
makeSelectFetchingChannelClaims,
|
2021-11-11 12:48:10 +08:00
|
|
|
selectClaimIsMine,
|
2019-11-21 20:37:25 -05:00
|
|
|
makeSelectTotalPagesInChannelSearch,
|
2021-11-11 12:48:10 +08:00
|
|
|
selectClaimForUri,
|
2021-10-17 16:36:14 +08:00
|
|
|
} from 'redux/selectors/claims';
|
|
|
|
import { doResolveUris } from 'redux/actions/claims';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
2021-03-03 13:50:16 -05:00
|
|
|
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
2019-07-21 20:13:42 -04:00
|
|
|
import { withRouter } from 'react-router';
|
2020-06-15 16:33:03 -04:00
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2021-11-23 12:29:04 +08:00
|
|
|
import { selectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
|
2022-01-06 11:49:49 -06:00
|
|
|
import { doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
2021-12-22 10:12:44 -06:00
|
|
|
import { selectActiveLivestreamForChannel, selectActiveLivestreamInitialized } from 'redux/selectors/livestream';
|
|
|
|
import { getChannelIdFromClaim } from 'util/claim';
|
2021-07-06 09:29:46 +08:00
|
|
|
import ChannelContent from './view';
|
2019-05-06 22:35:04 -04:00
|
|
|
|
2019-07-21 20:13:42 -04:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { search } = props.location;
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const page = urlParams.get('page') || 0;
|
2021-11-11 12:48:10 +08:00
|
|
|
const claim = props.uri && selectClaimForUri(state, props.uri);
|
2021-12-22 10:12:44 -06:00
|
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
2021-11-11 12:48:10 +08:00
|
|
|
|
2019-07-21 20:13:42 -04:00
|
|
|
return {
|
2019-11-21 20:37:25 -05:00
|
|
|
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
|
2019-07-21 20:13:42 -04:00
|
|
|
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
|
2019-11-21 20:37:25 -05:00
|
|
|
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
|
2021-11-11 12:48:10 +08:00
|
|
|
channelIsMine: selectClaimIsMine(state, claim),
|
2021-03-03 13:50:16 -05:00
|
|
|
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
|
2021-11-11 12:48:10 +08:00
|
|
|
claim,
|
2020-03-26 17:47:07 -04:00
|
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
2021-03-31 16:55:26 -04:00
|
|
|
showMature: selectShowMatureContent(state),
|
2021-11-23 12:29:04 +08:00
|
|
|
tileLayout: selectClientSetting(state, SETTINGS.TILE_LAYOUT),
|
2021-12-22 10:12:44 -06:00
|
|
|
activeLivestreamForChannel: selectActiveLivestreamForChannel(state, channelClaimId),
|
|
|
|
activeLivestreamInitialized: selectActiveLivestreamInitialized(state),
|
2019-07-21 20:13:42 -04:00
|
|
|
};
|
|
|
|
};
|
2019-05-06 22:35:04 -04:00
|
|
|
|
2021-03-05 15:10:18 +08:00
|
|
|
const perform = (dispatch) => ({
|
2021-03-08 13:30:06 -05:00
|
|
|
doResolveUris: (uris, returnCachedUris) => dispatch(doResolveUris(uris, returnCachedUris)),
|
2022-01-06 11:49:49 -06:00
|
|
|
doFetchChannelLiveStatus: (channelID) => dispatch(doFetchChannelLiveStatus(channelID)),
|
2021-03-05 15:10:18 +08:00
|
|
|
});
|
|
|
|
|
2021-07-06 09:29:46 +08:00
|
|
|
export default withRouter(connect(select, perform)(ChannelContent));
|