2021-03-01 18:07:10 -08:00
|
|
|
import { connect } from 'react-redux';
|
2021-12-09 17:23:23 +08:00
|
|
|
import { makeSelectTagInClaimOrChannelForUri, selectClaimForUri } from 'redux/selectors/claims';
|
2022-03-15 13:18:08 -03:00
|
|
|
import { doSetPrimaryUri } from 'redux/actions/content';
|
2021-03-15 10:32:51 -04:00
|
|
|
import { doUserSetReferrer } from 'redux/actions/user';
|
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2021-06-03 11:55:16 -04:00
|
|
|
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
2022-04-29 10:54:14 -03:00
|
|
|
import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket';
|
2021-12-09 17:23:23 +08:00
|
|
|
import { getChannelIdFromClaim } from 'util/claim';
|
2022-03-15 13:28:55 -03:00
|
|
|
import {
|
|
|
|
selectActiveLivestreamForChannel,
|
|
|
|
selectActiveLivestreamInitialized,
|
2022-04-29 10:54:14 -03:00
|
|
|
selectSocketConnectionForId,
|
2022-03-15 13:28:55 -03:00
|
|
|
} from 'redux/selectors/livestream';
|
2022-04-29 10:54:14 -03:00
|
|
|
import { selectIsUriCurrentlyPlaying } from 'redux/selectors/content';
|
2022-03-16 08:35:58 -03:00
|
|
|
import { doFetchChannelLiveStatus } from 'redux/actions/livestream';
|
2021-03-15 10:32:51 -04:00
|
|
|
import LivestreamPage from './view';
|
2021-03-01 18:07:10 -08:00
|
|
|
|
2021-12-22 10:12:44 -06:00
|
|
|
const select = (state, props) => {
|
2022-01-14 17:24:16 -03:00
|
|
|
const { uri } = props;
|
2022-03-16 08:57:24 -03:00
|
|
|
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
2022-04-29 10:54:14 -03:00
|
|
|
const { claim_id: claimId, canonical_url } = claim || {};
|
2022-03-16 08:57:24 -03:00
|
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
2022-01-14 17:24:16 -03:00
|
|
|
|
2021-12-22 10:12:44 -06:00
|
|
|
return {
|
2022-03-16 08:57:24 -03:00
|
|
|
uri: canonical_url || '',
|
2021-12-22 10:12:44 -06:00
|
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
|
|
|
channelClaimId,
|
2022-01-14 17:24:16 -03:00
|
|
|
chatDisabled: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_COMMENTS_TAG)(state),
|
2021-12-22 10:12:44 -06:00
|
|
|
activeLivestreamForChannel: selectActiveLivestreamForChannel(state, channelClaimId),
|
|
|
|
activeLivestreamInitialized: selectActiveLivestreamInitialized(state),
|
2022-04-29 10:54:14 -03:00
|
|
|
socketConnection: selectSocketConnectionForId(state, claimId),
|
|
|
|
isStreamPlaying: selectIsUriCurrentlyPlaying(state, uri),
|
2021-12-22 10:12:44 -06:00
|
|
|
};
|
|
|
|
};
|
2021-03-01 18:07:10 -08:00
|
|
|
|
2021-12-16 15:59:13 -06:00
|
|
|
const perform = {
|
2022-03-15 13:18:08 -03:00
|
|
|
doSetPrimaryUri,
|
2021-03-15 10:32:51 -04:00
|
|
|
doUserSetReferrer,
|
2021-12-16 15:59:13 -06:00
|
|
|
doCommentSocketConnect,
|
2022-04-29 10:54:14 -03:00
|
|
|
doCommentSocketDisconnect,
|
2022-01-06 11:49:49 -06:00
|
|
|
doFetchChannelLiveStatus,
|
2021-12-16 15:59:13 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(select, perform)(LivestreamPage);
|