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