2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2020-09-17 19:11:19 +02:00
|
|
|
import {
|
2021-11-11 05:48:10 +01:00
|
|
|
selectClaimIsMine,
|
|
|
|
selectClaimForUri,
|
2021-11-08 07:27:14 +01:00
|
|
|
selectHasChannels,
|
2022-01-25 19:48:53 +01:00
|
|
|
makeSelectTagInClaimOrChannelForUri,
|
2022-05-19 23:39:09 +02:00
|
|
|
selectClaimIsNsfwForUri,
|
2022-06-24 15:08:46 +02:00
|
|
|
selectPreorderTagForUri,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/claims';
|
2022-02-01 21:11:35 +01:00
|
|
|
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
2022-05-10 14:01:19 +02:00
|
|
|
import { doPrepareEdit } from 'redux/actions/publish';
|
2021-11-19 03:40:01 +01:00
|
|
|
import { selectCostInfoForUri } from 'lbryinc';
|
2022-02-27 03:55:37 +01:00
|
|
|
import { doDownloadUri } from 'redux/actions/content';
|
2020-09-17 19:11:19 +02:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
2022-02-01 21:11:35 +01:00
|
|
|
import { doOpenModal } from 'redux/actions/app';
|
2020-04-01 20:43:50 +02:00
|
|
|
import FileActions from './view';
|
|
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
2022-01-25 19:48:53 +01:00
|
|
|
import { DISABLE_DOWNLOAD_BUTTON_TAG } from 'constants/tags';
|
2022-02-02 13:45:16 +01:00
|
|
|
import { isStreamPlaceholderClaim } from 'util/claim';
|
2022-07-11 16:12:37 +02:00
|
|
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2021-11-11 05:48:10 +01:00
|
|
|
const select = (state, props) => {
|
2022-02-01 21:11:35 +01:00
|
|
|
const { uri } = props;
|
|
|
|
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
2022-07-11 16:12:37 +02:00
|
|
|
const permanentUrl = (claim && claim.permanent_url) || '';
|
|
|
|
const isPostClaim = makeSelectFileRenderModeForUri(permanentUrl)(state) === RENDER_MODES.MARKDOWN;
|
2021-11-11 05:48:10 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
2022-02-01 21:11:35 +01:00
|
|
|
renderMode: makeSelectFileRenderModeForUri(uri)(state),
|
|
|
|
costInfo: selectCostInfoForUri(state, uri),
|
2021-11-11 05:48:10 +01:00
|
|
|
hasChannels: selectHasChannels(state),
|
2022-02-02 13:45:16 +01:00
|
|
|
isLivestreamClaim: isStreamPlaceholderClaim(claim),
|
2022-07-11 16:12:37 +02:00
|
|
|
isPostClaim,
|
2022-02-01 21:11:35 +01:00
|
|
|
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
2022-05-19 23:39:09 +02:00
|
|
|
disableDownloadButton: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_DOWNLOAD_BUTTON_TAG)(state),
|
|
|
|
isMature: selectClaimIsNsfwForUri(state, uri),
|
2022-06-24 15:08:46 +02:00
|
|
|
isAPreorder: Boolean(selectPreorderTagForUri(state, props.uri)),
|
2021-11-11 05:48:10 +01:00
|
|
|
};
|
|
|
|
};
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2022-02-01 21:11:35 +01:00
|
|
|
const perform = {
|
|
|
|
doOpenModal,
|
2022-05-10 14:01:19 +02:00
|
|
|
doPrepareEdit,
|
2022-02-01 21:11:35 +01:00
|
|
|
doToast,
|
|
|
|
doDownloadUri,
|
|
|
|
};
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2020-04-01 20:43:50 +02:00
|
|
|
export default connect(select, perform)(FileActions);
|