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,
|
2021-11-16 04:52:35 +01:00
|
|
|
selectIsStreamPlaceholderForUri,
|
2021-06-03 17:55:16 +02:00
|
|
|
makeSelectTagInClaimOrChannelForUri,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/claims';
|
|
|
|
import { makeSelectStreamingUrlForUri, makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
|
|
|
import { doPrepareEdit } from 'redux/actions/publish';
|
2021-06-03 17:55:16 +02:00
|
|
|
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
2021-11-19 03:40:01 +01:00
|
|
|
import { selectCostInfoForUri } from 'lbryinc';
|
2021-06-18 15:56:20 +02:00
|
|
|
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
|
2020-09-17 19:11:19 +02:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
2021-06-18 15:56:20 +02:00
|
|
|
import { doOpenModal, doSetActiveChannel, doSetIncognito, doAnalyticsView } from 'redux/actions/app';
|
2020-01-06 19:32:35 +01:00
|
|
|
import fs from 'fs';
|
2020-04-01 20:43:50 +02:00
|
|
|
import FileActions from './view';
|
|
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2021-11-11 05:48:10 +01:00
|
|
|
const select = (state, props) => {
|
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
|
|
|
|
|
|
|
return {
|
|
|
|
claim,
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
|
|
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
|
|
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
2021-11-19 03:40:01 +01:00
|
|
|
costInfo: selectCostInfoForUri(state, props.uri),
|
2021-11-11 05:48:10 +01:00
|
|
|
hasChannels: selectHasChannels(state),
|
2021-11-16 04:52:35 +01:00
|
|
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, props.uri),
|
2021-11-11 05:48:10 +01:00
|
|
|
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
|
|
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
|
|
|
};
|
|
|
|
};
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2021-02-15 17:58:04 +01:00
|
|
|
const perform = (dispatch) => ({
|
2018-10-29 18:23:53 +01:00
|
|
|
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
2021-02-15 17:58:04 +01:00
|
|
|
prepareEdit: (publishData, uri, fileInfo) => {
|
|
|
|
if (publishData.signing_channel) {
|
2021-03-25 14:16:18 +01:00
|
|
|
dispatch(doSetIncognito(false));
|
2021-02-15 17:58:04 +01:00
|
|
|
dispatch(doSetActiveChannel(publishData.signing_channel.claim_id));
|
|
|
|
} else {
|
|
|
|
dispatch(doSetIncognito(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(doPrepareEdit(publishData, uri, fileInfo, fs));
|
|
|
|
},
|
2020-12-21 16:31:34 +01:00
|
|
|
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
2021-02-15 17:58:04 +01:00
|
|
|
doToast: (options) => dispatch(doToast(options)),
|
2021-06-18 15:56:20 +02:00
|
|
|
download: (uri) => dispatch(doPlayUri(uri, false, true, () => dispatch(doAnalyticsView(uri)))),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2020-04-01 20:43:50 +02:00
|
|
|
export default connect(select, perform)(FileActions);
|